FFmpegArgs 1.1.0
.NET 5.0
.NET Standard 2.0
.NET Framework 4.6.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
Install-Package FFmpegArgs -Version 1.1.0
dotnet add package FFmpegArgs --version 1.1.0
<PackageReference Include="FFmpegArgs" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FFmpegArgs --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FFmpegArgs, 1.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install FFmpegArgs as a Cake Addin
#addin nuget:?package=FFmpegArgs&version=1.1.0
// Install FFmpegArgs as a Cake Tool
#tool nuget:?package=FFmpegArgs&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FFmpegArgs
Easy to use
FFmpegArg ffmpegArg = new FFmpegArg().OverWriteOutput();
var green_video = ffmpegArg.AddVideoInput(new VideoFileInput(@"chromakey.mp4")
.SsPosition(TimeSpan.FromSeconds(0.5)));
var background_video = ffmpegArg.AddVideoInput(new VideoFileInput(@"background.mp4")
.SsPosition(TimeSpan.FromSeconds(1))
.ToPosition(TimeSpan.FromSeconds(10)));
var color_keys = green_video.ImageMaps.First()
.ColorKeyFilter(Color.FromArgb(101, 220, 8)).Similarity(0.25f)//ColorKey
.Enable("between(t,0,10)").MapOut//ITimelineSupport
.ScaleFilter("iw/3", "ih/3").MapOut
.SplitFilter(2).MapsOut;//Scale
var overlay = color_keys.First()
//overlay color_key on-center background_video
.OverlayFilterOn(background_video.ImageMaps.First(), "(W-w)/2", "(H-h)/2").MapOut;
ffmpegArg.AddOutput(new VideoFileOutput(@"out.mp4", overlay, background_video.AudioMaps.First()).Fps(24));
ffmpegArg.AddOutput(new VideoFileOutput(@"out2.mp4", color_keys.Last(), background_video.AudioMaps.First()).Fps(30));
var renderResult = ffmpegArg
.Render(c => c
.WithFFmpegBinaryPath("path to ffmpeg.exe")
.WithWorkingDirectory(Directory.GetCurrentDirectory()))
.Execute();
For more example, see FFmpegArgs.Test
Easy extend
//filter
public class PadFilter : ImageToImageFilter
{
static readonly IEnumerable<string> _variables = new List<string>()
{
"in_w", "in_h", "iw", "ih",
"out_w", "out_h", "ow", "oh",
"x","y","a","sar","dar",
"hsub", "vsub"
};
readonly FFmpegExpression expression = new FFmpegExpression(_variables);
internal PadFilter(Action<FFmpegExpression> w, Action<FFmpegExpression> h, ImageMap imageMap) : base("pad", imageMap)
{
AddMapOut();
this.SetOption("w", w.Run(expression));
this.SetOption("h", h.Run(expression));
}
public PadFilter Position(Action<FFmpegExpression> x, Action<FFmpegExpression> y)
=> this.SetOption("x", x.Run(expression)).SetOption("y", y.Run(expression));
public PadFilter Position(string x, string y)
=> Position(x.Expression(), y.Expression());
public PadFilter Color(Color color)
=> this.SetOption("color", color.ToHexStringRGBA());
public PadFilter Eval(ScaleEval eval)
=> this.SetOption("eval", eval.ToString().ToLower());
}
public static class PadFilterExtension
{
public static PadFilter PadFilter(this ImageMap imageMap, Action<FFmpegExpression> w, Action<FFmpegExpression> h)
{
return new PadFilter(w, h, imageMap ?? throw new ArgumentNullException(nameof(imageMap)));
}
}
//input
public static T FrameRate<T>(this T input, int r) where T : BaseInput
=> input.SetOption("-r", r);
//output
public static T VSync<T>(this T output,int vsync) where T : ImageOutput
=> output.SetOption("-vsync", vsync);
public static T ASync<T>(this T output, int async) where T : AudioOutput
=> output.SetOption("-async", async);
//global
public static FFmpegArg OverWriteOutput(this FFmpegArg ffmpegArg)
=> ffmpegArg.SetFlag("-y");
ffmpeg expression check
//auto check with expression
img.ScaleFilter("iw/3", "ih/3")
//or
img.ScaleFilter(w => w.Check("iw/3"), h => h.Check("ih/3"))
//if expression bropblem
img.ScaleFilter(w => w.NonCheck("iw/3"), h => h.NonCheck("ih/3"));
LICENCE
Under ffmpeg licence
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.