Exemplo n.º 1
0
        public string WritePart()
        {
            Files.ForEach(file =>
            {
                FFMPEGCommand.AddInput(file);
            });

            FilterComplexFlag filterComplexFlag = new FilterComplexFlag();

            for (int n = 0; n < Files.Count - 1; n++)
            {
                string resultingBaseFromPrevious = (n == 0) ? "0" : "res" + n;
                filterComplexFlag.AddFilterComplexExpression(new FilterComplexExpression()
                                                             .AddInputIdentifier(resultingBaseFromPrevious)
                                                             .AddInputIdentifier($"{n + 1}")
                                                             .AddFilter(new Filter()
                                                                        .SetName("concat")
                                                                        .AddAttribute("n", "2")
                                                                        )
                                                             .SetOutputIdentifier((n < Files.Count - 2) ? $"res{n + 1}" : "")
                                                             );
            }

            FFMPEGCommand.AddFlag(filterComplexFlag);

            return(FFMPEGCommand.WritePart());
        }
Exemplo n.º 2
0
        public string WritePart()
        {
            FFMPEGCommand.AddInput(InputVideoPath);

            string dimensionString = $"{VideoDimensions.Width.ToString()}:{VideoDimensions.Height.ToString()}";

            FFMPEGCommand.AddFlag(new SimpleFlag("vf", $"scale={dimensionString}"));

            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));

            return(FFMPEGCommand.WritePart());
        }
        public string WritePart()
        {
            FFMPEGCommand.AddInput(InputImagePath);

            string dimensionString = $"{ImageDimensions.Width.ToString()}:{ImageDimensions.Height.ToString()}";

            // fix for .png transparency thumbnails
            FFMPEGCommand.AddFlag(new SimpleFlag("filter_complex", $"\"[0]scale={dimensionString}[scaled];[scaled]split = 2[bg][fg];[bg] drawbox=c=0xCCCCCC:replace=1:t=fill[bg];[bg] [fg] overlay\" -f image2 "));

            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));

            return(FFMPEGCommand.WritePart());
        }
Exemplo n.º 4
0
        public static void Execute(FFMPEGCommand fFMPEGCommand)
        {
            using (Process ffmpeg = new Process())
            {
                ffmpeg.StartInfo.FileName         = fFMPEGCommand.WriteExecutePath();
                ffmpeg.StartInfo.WorkingDirectory = Path.GetDirectoryName(ffmpeg.StartInfo.FileName);
                ffmpeg.StartInfo.UseShellExecute  = false;

                ffmpeg.StartInfo.Arguments = fFMPEGCommand.WriteArguments();
                //ffmpeg.StartInfo.RedirectStandardError = true;
                ffmpeg.Start();
                ffmpeg.WaitForExit();
            }
        }
Exemplo n.º 5
0
        public string WritePart()
        {
            //StringBuilder sb = new StringBuilder();

            FFMPEGCommand.AddFlag(new SimpleFlag("i", VideoPath));
            FFMPEGCommand.AddFlag(new SimpleFlag("itsoffset", OffsetAdjustment.ToString()));
            FFMPEGCommand.AddFlag(new SimpleFlag("i", VideoPath));
            FFMPEGCommand.AddFlag(new SimpleFlag("vcodec", "copy"));
            FFMPEGCommand.AddFlag(new SimpleFlag("acodec", "copy"));
            FFMPEGCommand.AddFlag(new SimpleFlag("map", "0:0"));
            FFMPEGCommand.AddFlag(new SimpleFlag("map", "1:1"));
            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));


            return(FFMPEGCommand.WritePart());
        }
        public string WritePart()
        {
            FFMPEGCommand.AddInput(InputVideoPath);

            FFMPEGCommand.AddFlag(new SimpleFlag("ss", ExtractAtSecondMark.ToString()));
            FFMPEGCommand.AddFlag(new SimpleFlag("vframes", "1"));

            if (ImageDimensions != null)
            {
                string dimensionString = $"{ImageDimensions.Width.ToString()}x{ImageDimensions.Height.ToString()}";
                FFMPEGCommand.AddFlag(new SimpleFlag("s", dimensionString));
            }

            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));

            return(FFMPEGCommand.WritePart());
        }
Exemplo n.º 7
0
        public string WritePart()
        {
            FFMPEGCommand.AddInput(InputVideoPath);

            if (SamplingFrequency > 0)
            {
                FFMPEGCommand.AddFlag(new SimpleFlag("ar", SamplingFrequency.ToString()));
            }

            if (!string.IsNullOrEmpty(BitRate))
            {
                FFMPEGCommand.AddFlag(new SimpleFlag("b:a", BitRate));
            }

            if (NumAudioChannels >= 2)
            {
                FFMPEGCommand.AddFlag(new SimpleFlag("ac", NumAudioChannels.ToString()));
            }

            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));

            return(FFMPEGCommand.WritePart());
        }
Exemplo n.º 8
0
 public ConcatenateCommand SetOutput(string output)
 {
     FFMPEGCommand.SetOutput(output);
     return(this);
 }
 public ResizeImageCommand SetOutput(string outputImagePath)
 {
     FFMPEGCommand.SetOutput(outputImagePath);
     return(this);
 }
Exemplo n.º 10
0
 public VideoAudioSyncCommand SetOutput(string output)
 {
     FFMPEGCommand.SetOutput(output);
     return(this);
 }
Exemplo n.º 11
0
        public string WritePart()
        {
            FFMPEGCommand.AddInput(BaseVideoPath);

            foreach (OverlayVideo overlayVideo in OverlayVideos)
            {
                FFMPEGCommand.AddInput(overlayVideo.Path);
            }

            FilterComplexFlag filterComplexFlag = new FilterComplexFlag();

            // Add the first expression, and that is to merge the first video and the base
            for (int n = 0; n < OverlayVideos.Count; n++)
            {
                OverlayVideo overlayVideo = OverlayVideos[n];


                string resultingBaseFromPrevious = (n == 0) ? "0:v" : "res" + n;

                FilterComplexExpression timingExpression = new FilterComplexExpression()
                                                           .AddInputIdentifier($"{n + 1}")
                                                           .AddFilter(new Filter()
                                                                      .SetName("setpts")
                                                                      .SetValue($"PTS+{OverlayVideos[n].StartOffsetInSeconds}/TB")
                                                                      )
                                                           .SetOutputIdentifier($"top{n + 1}");

                if (overlayVideo.Dimension.Width > 0 || overlayVideo.Dimension.Height > 0)
                {
                    timingExpression.AddFilter(new Filter()
                                               .SetName("scale")
                                               .SetValue($"{overlayVideo.Dimension.Width.ToString()}:{overlayVideo.Dimension.Height.ToString()}")
                                               );
                }

                filterComplexFlag.AddFilterComplexExpression(timingExpression);

                int startOffset = OverlayVideos[n].StartOffsetInSeconds;
                int until       = startOffset + OverlayVideos[n].DurationInSeconds;

                Filter overlayFilter = new Filter()
                                       .SetName("overlay")
                                       .AddAttribute("enable", $"'between(t, {startOffset}, {until})'");

                if (overlayVideo.Coordinate.X > 0 || overlayVideo.Coordinate.Y > 0)
                {
                    overlayFilter.AddAttribute("x", overlayVideo.Coordinate.X.ToString())
                    .AddAttribute("y", overlayVideo.Coordinate.Y.ToString());
                }

                filterComplexFlag.AddFilterComplexExpression(new FilterComplexExpression()
                                                             .AddInputIdentifier(resultingBaseFromPrevious)
                                                             .AddInputIdentifier($"top{n + 1}")
                                                             .AddFilter(overlayFilter)
                                                             .SetOutputIdentifier((n < OverlayVideos.Count - 1) ? $"res{n + 1}" : "")
                                                             );
            }

            FFMPEGCommand.AddFlag(filterComplexFlag);
            FFMPEGCommand.AddFlag(new SimpleFlag("y", null));

            return(FFMPEGCommand.WritePart());
        }
Exemplo n.º 12
0
 public SuperImposeCommand SetOutput(string output)
 {
     FFMPEGCommand.SetOutput(output);
     return(this);
 }
 public ExtractFrameCommand SetOutput(string outputImagePath)
 {
     FFMPEGCommand.SetOutput(outputImagePath);
     return(this);
 }
Exemplo n.º 14
0
 public ExtractAudioCommand SetOutput(string outputVideoPath)
 {
     FFMPEGCommand.SetOutput(outputVideoPath);
     return(this);
 }
Exemplo n.º 15
0
 public ResizeVideoCommand SetOutput(string outputVideoPath)
 {
     FFMPEGCommand.SetOutput(outputVideoPath);
     return(this);
 }