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()); }
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()); }
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()); }
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()); }
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()); }