示例#1
0
        public void Cut(FFMpegCutOptions cutOptions, bool muteProgress = false)
        {
            EnsureFileDoesNotExist(cutOptions.OutputFile);
            var cutCommandBuilder = new FFMpegCommandBuilder(this.temporaryFilesStorage)
                                    .StartFrom(cutOptions.Start)
                                    .InputFrom(cutOptions.InputFile)
                                    .DurationIs(cutOptions.Duration)
                                    .OutputVideoCodec(cutOptions.VideoCodec)
                                    .OutputAudioCodec(cutOptions.AudioCodec);

            if (!cutOptions.SimpleMode)
            {
                cutCommandBuilder = cutCommandBuilder.OutputScale(cutOptions.OutputSize);
            }
            cutCommandBuilder = cutCommandBuilder
                                .AppendCustom("-avoid_negative_ts 1 -max_muxing_queue_size 1000")
                                .OutputTo(cutOptions.OutputFile);
            if (!muteProgress)
            {
                cutCommandBuilder = cutCommandBuilder.WithProgressCallback(cutOptions.GlobalExportProgress.SetCurrentOperationProgress);
            }
            var command = cutCommandBuilder.WithStopSignal(this.stopSignal)
                          .WithPriority(this.ffmpegProcessPriorityClass)
                          .BuildCommand(pathToFfMpegExe);

            this.ExecuteFFMpegCommand(command, "CUT");
            if (!muteProgress)
            {
                cutOptions.GlobalExportProgress.IncreaseOperationsDone(command.ProcessId);
            }
        }
示例#2
0
        public void CutAndDrawText(FFMpegCutOptions cutOptions, List <TextTimeRecord> overlayText)
        {
            EnsureFileDoesNotExist(cutOptions.OutputFile);
            if (!overlayText.Any())
            {
                this.Cut(cutOptions);
                return;
            }
            var lastDot          = cutOptions.InputFile.LastIndexOf('.');
            var inputExt         = cutOptions.InputFile.Substring(lastDot);
            var intermediateFile = this.temporaryFilesStorage.GetIntermediateFile(inputExt);

            this.Cut(cutOptions.CloneWithOtherOutput(intermediateFile));
            this.DrawText(intermediateFile, overlayText, cutOptions.OutputFile, cutOptions.GlobalExportProgress);
        }