コード例 #1
0
ファイル: Camera.cs プロジェクト: chadly/cams
        bool ProcessFile(VideoFile file, string outputBase)
        {
            DateTime threshold = DateTime.Now.AddMinutes(Settings.MinutesToWaitBeforeProcessing);

            if (file.Date >= threshold)
            {
                Console.WriteLine($"File was written less than {Settings.MinutesToWaitBeforeProcessing} minutes ago: {file.FilePath}");
                return(false);
            }

            string outputFile = Path.Combine(outputBase, file.Date.ToString("yyyy-MM-dd"), Name, $"{file.Date.ToString("HH-mm-ss")}.{CONVERT_FOOTAGE_FORMAT}");
            string outputDir  = new FileInfo(outputFile).DirectoryName;

            Directory.CreateDirectory(outputDir);

            bool converted = true;

            if (file.HasExtension(CONVERT_FOOTAGE_FORMAT))
            {
                //clear if it already exists for some reason (previous process run failed?)
                File.Delete(outputFile);

                //save some time & just move the file directly rather than going through ffmpeg
                File.Move(file.FilePath, outputFile);
            }
            else if (!VideoConverter.CodecCopy(file.FilePath, outputFile))
            {
                converted = false;
                FallbackCopy(file, outputFile);
            }

            Cleanup(file);

            Console.WriteLine(converted ? $"Converted {outputFile}" : $"Failed to convert {outputFile}; copied instead");
            return(true);
        }
コード例 #2
0
ファイル: Camera.cs プロジェクト: chadly/cams
 protected abstract void Cleanup(VideoFile file);
コード例 #3
0
ファイル: Camera.cs プロジェクト: chadly/cams
 protected abstract void FallbackCopy(VideoFile file, string outputFile);
コード例 #4
0
 protected override void Cleanup(VideoFile file)
 {
     File.Delete(file.FilePath);
 }