xFFmpeg.NET
7.2.0
dotnet add package xFFmpeg.NET --version 7.2.0
NuGet\Install-Package xFFmpeg.NET -Version 7.2.0
<PackageReference Include="xFFmpeg.NET" Version="7.2.0" />
paket add xFFmpeg.NET --version 7.2.0
#r "nuget: xFFmpeg.NET, 7.2.0"
// Install xFFmpeg.NET as a Cake Addin #addin nuget:?package=xFFmpeg.NET&version=7.2.0 // Install xFFmpeg.NET as a Cake Tool #tool nuget:?package=xFFmpeg.NET&version=7.2.0
<img src="lib/ffmpeg/v4/icon.png" alt="drawing" width="24" height="24" /> FFmpeg.NET
FFmpeg.NET provides a straightforward interface for handling media data, making tasks such as converting, slicing and editing both audio and video completely effortless.
Under the hood, FFmpeg.NET is a .NET wrapper for FFmpeg; a free (LGPLv2.1) multimedia framework containing multiple audio and video codecs, supporting muxing, demuxing and transcoding tasks on many media formats.
Some major parts are taken from https://github.com/AydinAdn/MediaToolkit. Many features have been refactored. The library has been ported to Netstandard and made threadsafe.
You need to provide the ffmpeg executable path to the Engine
constructor.
Project Health
Service | Status |
---|---|
Travis CI |
Packages
Package | NuGet |
---|---|
xFFmpeg.NET |
Contents
Features
- Resolving metadata
- Generating thumbnails from videos
- Transcode audio & video into other formats using parameters such as:
Bit rate
Frame rate
Resolution
Aspect ratio
Seek position
Duration
Sample rate
Media format
- Convert media to physical formats and standards such as:
- Standards include:
FILM
,PAL
&NTSC
- Mediums include:
DVD
,DV
,DV50
,VCD
&SVCD
- Standards include:
- Supports custom FFmpeg command line arguments (NEW in v2.1.0)
- Raising progress events
Get started!
Install FFmpeg.NET from nuget.org Package Source using the Package Manager Console with the following command
PM> Install-Package xFFmpeg.NET
Samples
- Grab thumbnail from a video
- Retrieve metadata new Engine
- Perform basic video conversions
- Convert from FLV to DVD
- Convert FLV to MP4 using various transcoding options
- Cut / split video
- Subscribing to events
Grab thumbnail from a video
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var outputFile = new OutputFile (@"C:\Path\To_Save_Image.jpg");
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
// Saves the frame located on the 15th second of the video.
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(15) };
await ffmpeg.GetThumbnailAsync(inputFile, outputFile, options);
Retrieve metadata
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
var metadata = await ffmpeg.GetMetadataAsync(inputFile);
Console.WriteLine(metadata.Duration);
Basic conversion
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var outputFile = new OutputFile (@"C:\Path\To_Save_New_Video.mp4");
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
await ffmpeg.ConvertAsync(inputFile, outputFile);
Convert Flash video to DVD
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var outputFile = new OutputFile (@"C:\Path\To_Save_New_DVD.vob");
var conversionOptions = new ConversionOptions
{
Target = Target.DVD,
TargetStandard = TargetStandard.PAL
};
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
await ffmpeg.ConvertAsync(inputFile, outputFile, conversionOptions);
Transcoding options FLV to MP4
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var outputFile = new OutputFile (@"C:\Path\To_Save_New_Video.mp4");
var conversionOptions = new ConversionOptions
{
MaxVideoDuration = TimeSpan.FromSeconds(30),
VideoAspectRatio = VideoAspectRatio.R16_9,
VideoSize = VideoSize.Hd1080,
AudioSampleRate = AudioSampleRate.Hz44100
};
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
await ffmpeg.ConvertAsync(inputFile, outputFile, conversionOptions);
Cut video down to smaller length
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var outputFile = new OutputFile (@"C:\Path\To_Save_ExtractedVideo.flv");
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
var options = new ConversionOptions();
// This example will create a 25 second video, starting from the
// 30th second of the original video.
//// First parameter requests the starting frame to cut the media from.
//// Second parameter requests how long to cut the video.
options.CutMedia(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(25));
await ffmpeg.ConvertAsync(inputFile, outputFile, options);
Subscribe to events
public async Task StartConverting()
{
var inputFile = new InputFile (@"C:\Path\To_Video.flv");
var outputFile = new OutputFile (@"C:\Path\To_Save_New_Video.mp4");
var ffmpeg = new Engine("C:\\ffmpeg\\ffmpeg.exe");
ffmpeg.Progress += OnProgress;
ffmpeg.Data += OnData;
ffmpeg.Error += OnError;
ffmpeg.Complete += OnComplete;
await ffmpeg.ConvertAsync(inputFile, outputFile);
}
private void OnProgress(object sender, ConversionProgressEventArgs e)
{
Console.WriteLine("[{0} => {1}]", e.Input.FileInfo.Name, e.Output.FileInfo.Name);
Console.WriteLine("Bitrate: {0}", e.Bitrate);
Console.WriteLine("Fps: {0}", e.Fps);
Console.WriteLine("Frame: {0}", e.Frame);
Console.WriteLine("ProcessedDuration: {0}", e.ProcessedDuration);
Console.WriteLine("Size: {0} kb", e.SizeKb);
Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);
}
private void OnData(object sender, ConversionDataEventArgs e)
{
Console.WriteLine("[{0} => {1}]: {2}", e.Input.FileInfo.Name, e.Output.FileInfo.Name, e.Data);
}
private void OnComplete(object sender, ConversionCompleteEventArgs e)
{
Console.WriteLine("Completed conversion from {0} to {1}", e.Input.FileInfo.FullName, e.Output.FileInfo.FullName);
}
private void OnError(object sender, ConversionErrorEventArgs e)
{
Console.WriteLine("[{0} => {1}]: Error: {2}\n{3}", e.Input.FileInfo.Name, e.Output.FileInfo.Name, e.Exception.ExitCode, e.Exception.InnerException);
}
Licensing
- Forwards licensing of MediaToolkit
- FFmpeg.NET is licensed under the MIT license
- FFmpeg.NET uses FFmpeg, a multimedia framework which is licensed under the LGPLv2.1 license
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on xFFmpeg.NET:
Package | Downloads |
---|---|
IntralismManiaConverter
A tool that can convert mania maps to intralist and intralism maps to mania. |
|
CandyKingdom.Marcy
Package Description |
|
Kingsmartech.Smop.Com
Package Description |
|
videofucker
Package Description |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on xFFmpeg.NET:
Repository | Stars |
---|---|
yangzhongke/NETBookMaterials
|
|
bartekmotyl/simple-video-cutter
Windows-based tool for efficient browsing and cutting video footage
|
|
onionware-github/OnionMedia
Open-Source Mediaconverter and -downloader
|
|
CnGal/CnGalWebSite
CnGal是一个非营利性的,立志于收集整理国内制作组创作的中文Galgame/AVG的介绍、攻略、评测、感想等内容的资料性质的网站。
|
Version | Downloads | Last updated |
---|---|---|
7.2.0 | 33,835 | 10/26/2023 |
7.1.3 | 62,626 | 4/3/2022 |
7.1.2 | 1,055 | 4/3/2022 |
7.0.1 | 6,649 | 11/27/2021 |
6.0.0 | 24,694 | 6/27/2021 |
5.0.2 | 10,152 | 6/27/2021 |
5.0.1 | 5,130 | 3/12/2021 |
5.0.0 | 1,366 | 3/12/2021 |
3.4.0 | 77,986 | 11/15/2019 |
3.3.3 | 18,663 | 5/1/2019 |
3.3.2 | 1,214 | 4/30/2019 |
3.3.1 | 1,220 | 4/28/2019 |
3.3.0 | 1,326 | 4/26/2019 |
3.2.0 | 1,194 | 4/26/2019 |
3.1.0 | 16,418 | 11/20/2018 |
3.0.0 | 1,451 | 11/20/2018 |
2.1.0 | 1,563 | 11/19/2018 |
2.0.0 | 1,431 | 11/19/2018 |
1.1.9 | 1,801 | 11/15/2018 |
1.1.8 | 1,940 | 9/17/2018 |
1.0.0.1 | 2,478 | 5/26/2018 |
1.0.0 | 2,128 | 5/26/2018 |