示例#1
0
        public void Concat4ProblemVideosFromArturas_Test()
        {
            const string OutputFile    = OutputFolder + "4Episodes60SecConcat_SuperFast.mkv";
            const string FileToConcat1 = OutputFolder + "1EpisodeToConcat_SuperFast.mp4";
            const string FileToConcat2 = OutputFolder + "2EpisodeToConcat_SuperFast.mp4";
            const string FileToConcat3 = OutputFolder + "3EpisodeToConcat_SuperFast.mp4";
            const string FileToConcat4 = OutputFolder + "4EpisodeToConcat_SuperFast.mp4";

            string Source1 = SampleFiles.RealInputVideoAVI;
            string Source2 = SampleFiles.RealInputVideoAVI2;

            var ffmpeg      = new FFMpeg(this.temporaryFilesStorage);
            var cutOptions1 = FFMpegCutOptions.BuildCatOptionsWithConvertations(Source1, FileToConcat1, 300, 20, GlobalExportProgress.Empty, new Size(1280, 720));

            ffmpeg.Cut(cutOptions1);
            var cutOptions2 = FFMpegCutOptions.BuildCatOptionsWithConvertations(Source1, FileToConcat2, 500, 20, GlobalExportProgress.Empty, new Size(1280, 720));

            ffmpeg.Cut(cutOptions2);
            var cutOptions3 = FFMpegCutOptions.BuildCatOptionsWithConvertations(Source2, FileToConcat3, 100, 20, GlobalExportProgress.Empty, new Size(1280, 720));

            ffmpeg.Cut(cutOptions3);
            var cutOptions4 = FFMpegCutOptions.BuildCatOptionsWithConvertations(Source2, FileToConcat4, 300, 20, GlobalExportProgress.Empty, new Size(1280, 720));

            ffmpeg.Cut(cutOptions4);

            ffmpeg.Concat(OutputFile, "copy", "copy", GlobalExportProgress.Empty, FileToConcat3, FileToConcat4, FileToConcat1, FileToConcat2);

            Assert.IsTrue(File.Exists(OutputFile));
        }
示例#2
0
        public void Cut_Concat_Effect3Videos_Test()
        {
            const string OutputFile      = OutputFolder + "Cut_Effect_Concat3Videos.avi";
            const string FileToConcat1   = OutputFolder + "1EpisodeToConcat_tmp.avi";
            const string FileToConcat2   = OutputFolder + "2EpisodeToConcat_tmp.avi";
            const string FileToConcat2TW = OutputFolder + "2EpisodeToConcat_tmpTW.avi";
            const string FileToConcat3   = OutputFolder + "3EpisodeToConcat_tmp.avi";

            string source = Path.Combine(this.InputFolder, SampleFiles.RealInputVideoAVI2);

            var ffmpeg      = new FFMpeg(this.temporaryFilesStorage);
            var cutOptions1 = FFMpegCutOptions.BuildSimpleCatOptions(source, FileToConcat1, 100, 20, GlobalExportProgress.Empty);

            ffmpeg.Cut(cutOptions1);
            var cutOptions2 = FFMpegCutOptions.BuildSimpleCatOptions(source, FileToConcat2, 300, 20, GlobalExportProgress.Empty);

            ffmpeg.Cut(cutOptions2);
            var cutOptions3 = FFMpegCutOptions.BuildSimpleCatOptions(source, FileToConcat3, 600, 20, GlobalExportProgress.Empty);

            ffmpeg.Cut(cutOptions3);

            ffmpeg.Concat(OutputFile, "copy", "copy", GlobalExportProgress.Empty, FileToConcat1, FileToConcat2, FileToConcat3);
            ffmpeg.ApplyTimeWarp(OutputFile, new List <TimeWarpRecord> {
                new TimeWarpRecord(23, 32, 2), new TimeWarpRecord(43, 52, 2)
            }, FileToConcat2TW, GlobalExportProgress.Empty);

            Assert.IsTrue(File.Exists(OutputFile));
        }
示例#3
0
        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);
        }
示例#4
0
        public void Cut_Effect_Concat3Videos_Test()
        {
            const string OutputFile    = OutputFolder + "3Episodes60SecConcat_tmp.avi";
            const string FileToConcat1 = OutputFolder + "1EpisodeToConcat_tmp.avi";
            const string FileToConcat2 = OutputFolder + "2EpisodeToConcat_tmp.avi";
            const string FileToConcat3 = OutputFolder + "3EpisodeToConcat_tmp.avi";

            string source = Path.Combine(this.InputFolder, SampleFiles.RealInputVideoAVI2);

            var ffmpeg      = new FFMpeg(this.temporaryFilesStorage);
            var cutOptions1 = FFMpegCutOptions.BuildCatOptionsWithConvertations(source,
                                                                                FileToConcat1,
                                                                                900,
                                                                                20,
                                                                                GlobalExportProgress.Empty,
                                                                                Size.Empty,
                                                                                null,
                                                                                new List <DrawImageTimeRecord>(),
                                                                                new List <TimeWarpRecord>());

            ffmpeg.Cut(cutOptions1);
            var cutOptions2 = FFMpegCutOptions.BuildCatOptionsWithConvertations(source,
                                                                                FileToConcat2,
                                                                                300,
                                                                                20,
                                                                                GlobalExportProgress.Empty,
                                                                                Size.Empty,
                                                                                null,
                                                                                new List <DrawImageTimeRecord>(),
                                                                                new List <TimeWarpRecord>
            {
                new TimeWarpRecord(3, 12, 2)
            });

            ffmpeg.Cut(cutOptions2);
            var cutOptions3 = FFMpegCutOptions.BuildCatOptionsWithConvertations(source,
                                                                                FileToConcat3,
                                                                                600,
                                                                                20,
                                                                                GlobalExportProgress.Empty,
                                                                                Size.Empty,
                                                                                null,
                                                                                new List <DrawImageTimeRecord>(),
                                                                                new List <TimeWarpRecord>
            {
                new TimeWarpRecord(3, 12, 2)
            });

            ffmpeg.Cut(cutOptions3);

            ffmpeg.Concat(OutputFile, "copy", "copy", GlobalExportProgress.Empty, FileToConcat2, FileToConcat1, FileToConcat3);

            Assert.IsTrue(File.Exists(OutputFile));
        }
示例#5
0
        public void SimpleCut_Test()
        {
            const string OutputFile = OutputFolder + "Simple20SecCut_Medium.mp4";
            var          ffmpeg     = new FFMpeg(this.temporaryFilesStorage);
            var          cutOptions = FFMpegCutOptions.BuildSimpleCatOptions(
                SampleFiles.RealInputVideoMP4,
                OutputFile,
                100,
                20,
                GlobalExportProgress.Empty);

            ffmpeg.Cut(cutOptions);

            Assert.IsTrue(File.Exists(OutputFile));
        }
示例#6
0
        public void CutFromTheEndOfLowQualityVideo_Test()
        {
            var          ffmpeg     = new FFMpeg(this.temporaryFilesStorage);
            const string OutputFile = OutputFolder + "CutFromTheEndOfLowQualityVideo.mp4";

            var cutOptions = FFMpegCutOptions.BuildCatOptionsWithConvertations(SampleFiles.LowQualityVideo,
                                                                               OutputFile,
                                                                               4000,
                                                                               20,
                                                                               GlobalExportProgress.Empty,
                                                                               new Size(640, 360));

            ffmpeg.Cut(cutOptions);

            Assert.IsTrue(File.Exists(OutputFile));
        }
示例#7
0
        private void CutAndDrawTextAndDrawImageAndApplyTimeWarp(
            FFMpeg ffMpeg,
            FFMpegCutOptions cutOptions,
            TemporaryFilesStorage temporaryFilesStorage)
        {
            EnsureFileDoesNotExist(cutOptions.OutputFile);
            var extensionForResultFile = Path.GetExtension(cutOptions.OutputFile);
            var imagesExist            = cutOptions.ImagesTimeTable != null && cutOptions.ImagesTimeTable.Any();
            var timeWarpExists         = cutOptions.TimeWarps != null && cutOptions.TimeWarps.Any();

            if (!cutOptions.OverlayText.Any() && !imagesExist && !timeWarpExists)
            {
                ffMpeg.Cut(cutOptions);
                return;
            }
            var intermediateFile1 = temporaryFilesStorage.GetIntermediateFile(extensionForResultFile);

            ffMpeg.Cut(cutOptions.CloneWithOtherOutput(intermediateFile1));

            if (cutOptions.OverlayText.Any())
            {
                var intermediateFile2 = (imagesExist || timeWarpExists) ? temporaryFilesStorage.GetIntermediateFile(extensionForResultFile) : cutOptions.OutputFile;
                ffMpeg.DrawText(intermediateFile1, cutOptions.OverlayText, intermediateFile2, cutOptions.GlobalExportProgress);
                File.Delete(intermediateFile1);
                intermediateFile1 = intermediateFile2;
            }
            if (imagesExist)
            {
                var intermediateFile3 = timeWarpExists ? temporaryFilesStorage.GetIntermediateFile(extensionForResultFile) : cutOptions.OutputFile;
                ffMpeg.DrawImage(intermediateFile1, cutOptions.ImagesTimeTable, intermediateFile3, cutOptions.GlobalExportProgress);
                File.Delete(intermediateFile1);
                intermediateFile1 = intermediateFile3;
            }
            if (timeWarpExists)
            {
                ffMpeg.ApplyTimeWarp(intermediateFile1, cutOptions.TimeWarps, cutOptions.OutputFile, this.globalExportProgress);
                File.Delete(intermediateFile1);
            }
        }