Last active
April 26, 2023 13:14
-
-
Save tqk2811/9f2f074fc973b5471b5f1526665c3e41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://github.com/tqk2811/FFmpegArgs | |
FFmpegArg ffmpegArg = new FFmpegArg(); | |
var colorInput = new FilterGraphInput(); | |
colorInput.FilterGraph.ColorFilter().Size(new Size(width,height)).Color(Color.Transparent); | |
var colorVideo = ffmpegArg.AddVideoInput(colorInput,1,0); | |
var colorMap = colorVideo.ImageMaps.First(); | |
List<ImageMap> maps = new List<ImageMap>(); | |
foreach(var input in inputs) | |
{ | |
var videoMap = ffmpegArg.AddVideoInput(new VideoFileInput(input.FileName),1,0); | |
var imageMap = videoMap.ImageMaps.First(). | |
.ScaleFilter()//scale save ratio | |
.W($"if(gte(iw/ih,{width}/{height}),min(iw,{width}),-1)") | |
.H($"if(gte(iw/ih,{width}/{height}),-1,min(ih,{height}))").MapOut | |
.SetSarFilter().Ratio("1/1").MapOut | |
.OverlayFilterOn(colorMap) | |
.X("(main_w - overlay_w)/2") | |
.Y("(main_h-overlay_h)/2") | |
.EofAction(EofAction.EndAll).MapOut//center | |
maps.Add(imageMap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment