public static FFMpegCutOptions BuildCatOptionsWithConvertations(
     string inputFile,
     string outputFile,
     double start,
     double duration,
     IGlobalExportProgress globalExportProgress,
     Size outputSize,
     string videoCodec,
     string audioCodec,
     List <TextTimeRecord> overlayText,
     List <DrawImageTimeRecord> images,
     List <TimeWarpRecord> timeWarps)
 {
     return(new FFMpegCutOptions(
                inputFile,
                outputFile,
                start,
                duration,
                globalExportProgress,
                outputSize,
                videoCodec,
                audioCodec,
                overlayText,
                images,
                timeWarps));
 }
 public static FFMpegCutOptions BuildSimpleCatOptions(
     string inputFile,
     string outputFile,
     double start,
     double duration,
     IGlobalExportProgress globalExportProgress)
 {
     return(new FFMpegCutOptions(inputFile, outputFile, start, duration, "copy", "copy", globalExportProgress));
 }
 public static FFMpegCutOptions BuildCatOptionsWithConvertations(
     string inputFile,
     string outputFile,
     double start,
     double duration,
     IGlobalExportProgress globalExportProgress,
     Size outputSize)
 {
     return(new FFMpegCutOptions(inputFile, outputFile, start, duration, globalExportProgress, outputSize, DefaultVideoCodec, DefaultAudioCodec, null, null, null));
 }
Beispiel #4
0
 public EpisodesRendererAllFiltersInSingleCommands(
     IList <VideoRenderOption> videoRenderOptions,
     string outputFile,
     Size outputSize,
     ProcessPriorityClass rendererProcessPriorityClass,
     IGlobalExportProgress globalExportProgress,
     CancellationToken cancellationToken)
 {
     this.cancellationToken            = cancellationToken;
     this.VideoRenderOptions           = videoRenderOptions;
     this.outputFile                   = outputFile;
     this.OutputSize                   = outputSize;
     this.rendererProcessPriorityClass = rendererProcessPriorityClass;
     this.globalExportProgress         = globalExportProgress;
 }
Beispiel #5
0
        public void Convert(string inputFile, string outputFile, IGlobalExportProgress globalExportProgress)
        {
            EnsureFileDoesNotExist(outputFile);
            var command = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                          .AppendCustom("-fflags +genpts")
                          .InputFrom(inputFile)
                          .OutputVideoCodec("copy")
                          .OutputAudioCodec("copy -map 0")
                          .OutputTo(outputFile)
                          .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                          .WithStopSignal(this.stopSignal)
                          .WithPriority(this.ffmpegProcessPriorityClass)
                          .BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "CONVERT");
            globalExportProgress.IncreaseOperationsDone(command.ProcessId);
        }
 private FFMpegCutOptions(
     string inputFile,
     string outputFile,
     double start,
     double duration,
     string videoCodec,
     string audioCodec,
     IGlobalExportProgress globalExportProgress)
 {
     this.InputFile            = inputFile;
     this.OutputFile           = outputFile;
     this.Start                = start;
     this.Duration             = duration;
     this.GlobalExportProgress = globalExportProgress;
     this.VideoCodec           = videoCodec;
     this.AudioCodec           = audioCodec;
     this.SimpleMode           = true;
 }
 private FFMpegCutOptions(
     string inputFile,
     string outputFile,
     double start,
     double duration,
     IGlobalExportProgress globalExportProgress,
     Size outputSize,
     string videoCodec,
     string audioCodec,
     IEnumerable <TextTimeRecord> overlayText,
     IEnumerable <DrawImageTimeRecord> imagesTimeTable,
     IEnumerable <TimeWarpRecord> timeWarps)
     : this(inputFile, outputFile, start, duration, videoCodec, audioCodec, globalExportProgress)
 {
     this.OutputSize      = outputSize;
     this.SimpleMode      = false;
     this.OverlayText     = overlayText?.ToList();
     this.ImagesTimeTable = imagesTimeTable?.ToList();
     this.TimeWarps       = timeWarps?.ToList();
 }
        private void ProcessRenderOptions(VideoRenderOption videoRenderOption, bool plainConcatIsPossible, IGlobalExportProgress globalExportProgress, Size outputSize)
        {
            var tempFile = this.temporaryFilesStorage.GetIntermediateFile(this.OutputExtension);

            var cutOptions = plainConcatIsPossible
                                 ? FFMpegCutOptions.BuildSimpleCatOptions(
                videoRenderOption.FilePath,
                tempFile,
                videoRenderOption.StartSecond,
                videoRenderOption.DurationSeconds,
                globalExportProgress)
                                 : FFMpegCutOptions.BuildCatOptionsWithConvertations(
                videoRenderOption.FilePath,
                tempFile,
                videoRenderOption.StartSecond,
                videoRenderOption.DurationSeconds,
                globalExportProgress,
                outputSize,
                videoRenderOption.OverlayTextTimeTable,
                videoRenderOption.ImagesTimeTable,
                videoRenderOption.TimeWarpSettings);

            this.CutOptions.Add(cutOptions);
            this.FilesToConcat.Add(tempFile);
        }
Beispiel #9
0
        public void ApplyTimeWarp(string inputFile, IList <TimeWarpRecord> timeWarps, string outputFile, IGlobalExportProgress globalExportProgress)
        {
            EnsureFileDoesNotExist(outputFile);
            var cutCommandBuilder = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                                    .InputFrom(inputFile)
                                    .ApplyTimeWarp(timeWarps)
                                    .OutputTo(outputFile)
                                    .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                                    .WithStopSignal(this.stopSignal)
                                    .WithPriority(this.ffmpegProcessPriorityClass);
            var command = cutCommandBuilder.BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "TIME_WARP");
            globalExportProgress.IncreaseOperationsDone(command.ProcessId, 1);
        }
 public CutOptionsBuilder(IList <VideoRenderOption> videoRenderOptions, Size outputSize, IGlobalExportProgress globalExportProgress, TemporaryFilesStorage temporaryFilesStorage, bool ignoreOverlays)
 {
     this.temporaryFilesStorage = temporaryFilesStorage;
     this.BuildCutOptions(videoRenderOptions, outputSize, globalExportProgress, ignoreOverlays);
 }
Beispiel #11
0
        public void Concat(string outputFile, Size outputSize, string vCodec, string aCodec, IGlobalExportProgress globalExportProgress, params string[] inputFiles)
        {
            EnsureFileDoesNotExist(outputFile);
            var command = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                          .ConcatInputsFrom(inputFiles)
                          .OutputVideoCodec(vCodec)
                          .OutputPreset(PresetParameters.SuperFast)
                          .OutputAudioCodec(aCodec)
                          .OutputTo(outputFile)
                          .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                          .WithStopSignal(this.stopSignal)
                          .WithPriority(this.ffmpegProcessPriorityClass)
                          .BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "CONCAT");
            globalExportProgress.IncreaseOperationsDone(command.ProcessId);
        }
Beispiel #12
0
 public void Concat(string outputFile, string vCodec, string aCodec, IGlobalExportProgress globalExportProgress, params string[] inputFiles)
 {
     this.Concat(outputFile, Size.Empty, vCodec, aCodec, globalExportProgress, inputFiles);
 }
Beispiel #13
0
        public void DrawImagesAndText(string inputFile, IList <DrawImageTimeRecord> imagesTimeTable, List <TextTimeRecord> overlayText, string outputFile, IGlobalExportProgress globalExportProgress)
        {
            EnsureFileDoesNotExist(outputFile);
            const int FontSize = 30;
            var       command  = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                                 .InputFrom(inputFile)
                                 .DrawImagesAndText(imagesTimeTable, overlayText, fontsPath, FontSize)
                                 .OutputVideoCodec(FFMpegCutOptions.DefaultVideoCodec)
                                 .OutputPreset(PresetParameters.SuperFast)
                                 .OutputAudioCodec(FFMpegCutOptions.DefaultAudioCodec)
                                 .OutputTo(outputFile)
                                 .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                                 .WithStopSignal(this.stopSignal)
                                 .WithPriority(this.ffmpegProcessPriorityClass)
                                 .BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "DrawText");
            globalExportProgress.IncreaseOperationsDone(command.ProcessId, Math.Max(imagesTimeTable.Count, overlayText.Count));
        }
Beispiel #14
0
        public void ConcatAndDrawImagesAndText(IList <string> inputFilesToConcat, IList <DrawImageTimeRecord> imagesTimeTable, List <TextTimeRecord> overlayText, Size finalScale, string outputFile, IGlobalExportProgress globalExportProgress)
        {
            EnsureFileDoesNotExist(outputFile);
            const int FontSizeFor1024Width = 30;
            var       fontSize             = finalScale.IsEmpty ? FontSizeFor1024Width : ((double)finalScale.Width / 1024) * FontSizeFor1024Width;
            var       command = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                                .ConcatDrawImagesAndText(inputFilesToConcat, imagesTimeTable, overlayText, finalScale, fontsPath, (int)fontSize)
                                .OutputVideoCodec(FFMpegCutOptions.DefaultVideoCodec)
                                .OutputPreset(PresetParameters.SuperFast)
                                .OutputAudioCodec(FFMpegCutOptions.DefaultAudioCodec)
                                .OutputTo(outputFile)
                                .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                                .WithStopSignal(this.stopSignal)
                                .WithPriority(this.ffmpegProcessPriorityClass)
                                .BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "DrawText");

            //одна операция для concat-a без постэффектов.
            var operationsCountForConcat = 1;
            var operationsCountForConcatAndDrawImagesAndText =
                Math.Max(operationsCountForConcat, Math.Max(imagesTimeTable.Count, overlayText.Count)) * 2;

            globalExportProgress.IncreaseOperationsDone(command.ProcessId, operationsCountForConcatAndDrawImagesAndText);
        }
Beispiel #15
0
        public void CutAndConcatAndDrawImagesAndText(IList <FFMpegCutInfo> cutInfosToConcat, IList <DrawImageTimeRecord> imagesTimeTable, List <TextTimeRecord> overlayText, Size finalScale, string outputFile, IGlobalExportProgress globalExportProgress)
        {
            EnsureFileDoesNotExist(outputFile);
            const int FontSizeFor1024Width = 30;
            var       fontSize             = finalScale.IsEmpty ? FontSizeFor1024Width : ((double)finalScale.Width / 1024) * FontSizeFor1024Width;
            var       command = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                                .CutConcatDrawImagesAndText(cutInfosToConcat, imagesTimeTable, overlayText, finalScale, fontsPath, (int)fontSize)
                                .OutputVideoCodec(FFMpegCutOptions.DefaultVideoCodec)
                                .OutputPreset(PresetParameters.SuperFast)
                                .OutputAudioCodec(FFMpegCutOptions.DefaultAudioCodec)
                                .Fix2FramesLeftError()
                                .OutputTo(outputFile)
                                .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                                .WithStopSignal(this.stopSignal)
                                .WithPriority(this.ffmpegProcessPriorityClass)
                                .BuildCommand(pathToFfMpegExe, cutInfosToConcat.Aggregate(0.0, (t, c) => t + c.EndSecond - c.StartSecond));

            this.ExecuteFFMpegCommand(command, "DrawText");

            globalExportProgress.IncreaseOperationsDone(command.ProcessId, 1);
        }
        private void BuildCutOptions(IList <VideoRenderOption> videoRenderOptions, Size outputSize, IGlobalExportProgress globalExportProgress, bool ignoreOverlays)
        {
            var plainConcatIsPossible = this.CheckWhetherPlainConcatIsPossible(videoRenderOptions, ignoreOverlays);

            this.OutputExtension = plainConcatIsPossible ? Path.GetExtension(videoRenderOptions.First().FilePath) : DefaultCutTempContainer;

            foreach (var videoRenderOption in videoRenderOptions)
            {
                this.ProcessRenderOptions(videoRenderOption, plainConcatIsPossible, globalExportProgress, outputSize);
            }
        }
Beispiel #17
0
 public EpisodesRendererAllFiltersInSingleCommandsTextAsImage(IList <VideoRenderOption> videoRenderOptions, string outputFile, Size outputSize, ProcessPriorityClass rendererProcessPriorityClass, IGlobalExportProgress globalExportProgress, CancellationToken cancellationToken) : base(videoRenderOptions, outputFile, outputSize, rendererProcessPriorityClass, globalExportProgress, cancellationToken)
 {
 }
Beispiel #18
0
        public void DrawImage(string inputFile, List <DrawImageTimeRecord> imagesTimeTable, string outputFile, IGlobalExportProgress globalExportProgress)
        {
            if (!imagesTimeTable.Any())
            {
                return;
            }
            EnsureFileDoesNotExist(outputFile);
            var command = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                          .InputFrom(inputFile)
                          .DrawImages(imagesTimeTable)
                          .OutputVideoCodec(FFMpegCutOptions.DefaultVideoCodec)
                          .OutputAudioCodec(FFMpegCutOptions.DefaultAudioCodec)
                          .OutputTo(outputFile)
                          .WithProgressCallback(globalExportProgress.SetCurrentOperationProgress)
                          .WithStopSignal(this.stopSignal)
                          .WithPriority(this.ffmpegProcessPriorityClass)
                          .BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "DrawImage");
            globalExportProgress.IncreaseOperationsDone(command.ProcessId);
        }