xFFmpeg.NET 1.0.0

.NET wrapper for common ffmpeg tasks.

There is a newer version of this package available.
See the version list below for details.
Install-Package xFFmpeg.NET -Version 1.0.0
dotnet add package xFFmpeg.NET --version 1.0.0
<PackageReference Include="xFFmpeg.NET" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add xFFmpeg.NET --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.

Uses ffmpeg v4 (win-x64) internally.

Contents

  1. Features
  2. Get started!
  3. Samples
  4. Licensing

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
  • Supports custom FFmpeg command line arguments
  • Raising progress events

Get started!

Install FFmpeg.NET from TeamCity Package Source using the Package Manager Console with the following command

PM> Install-Package xFFmpeg.NET

Samples

Grab thumbnail from a video

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_Image.jpg");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
// Saves the frame located on the 15th second of the video.
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(15) };
ffmpeg.GetThumbnail(inputFile, outputFile, options);

Retrieve metadata

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
var metadata = ffmpeg.GetMetadata(inputFile);

Console.WriteLine(metadata.Duration);

Basic conversion

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_New_Video.mp4");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
ffmpeg.Convert(inputFile, outputFile);

Convert Flash video to DVD

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_New_DVD.vob");

var conversionOptions = new ConversionOptions
{
    Target = Target.DVD, 
    TargetStandard = TargetStandard.PAL
};

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
ffmpeg.Convert(inputFile, outputFile, conversionOptions);

Transcoding options FLV to MP4

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"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 FFmpeg.NET.Engine.FFmpeg();
ffmpeg.Convert(inputFile, outputFile, conversionOptions);

Cut video down to smaller length

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_ExtractedVideo.flv");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
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));
ffmpeg.Convert(inputFile, outputFile, options);

Subscribe to events

public void StartConverting()
{
    var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
    var outputFile = new MediaFile (@"C:\Path\To_Save_New_Video.mp4");    

    var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
    ffmpeg.ConvertProgressEvent += ConvertProgressEvent;
    ffmpeg.ConversionCompleteEvent += ConversionCompleteEvent;
    ffmpeg.Convert(inputFile, outputFile);
}

private void ConvertProgressEvent(object sender, ConvertProgressEventArgs e)
{
    Console.WriteLine("\n------------\nConverting...\n------------");
    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("SizeKb: {0}", e.SizeKb);
    Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);
}

private void ConversionCompleteEvent(object sender, ConversionCompleteEventArgs e)
{
    Console.WriteLine("\n------------\nConversion complete!\n------------");
    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("SizeKb: {0}", e.SizeKb);
    Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);
}

Licensing

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.

Uses ffmpeg v4 (win-x64) internally.

Contents

  1. Features
  2. Get started!
  3. Samples
  4. Licensing

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
  • Supports custom FFmpeg command line arguments
  • Raising progress events

Get started!

Install FFmpeg.NET from TeamCity Package Source using the Package Manager Console with the following command

PM> Install-Package xFFmpeg.NET

Samples

Grab thumbnail from a video

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_Image.jpg");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
// Saves the frame located on the 15th second of the video.
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(15) };
ffmpeg.GetThumbnail(inputFile, outputFile, options);

Retrieve metadata

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
var metadata = ffmpeg.GetMetadata(inputFile);

Console.WriteLine(metadata.Duration);

Basic conversion

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_New_Video.mp4");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
ffmpeg.Convert(inputFile, outputFile);

Convert Flash video to DVD

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_New_DVD.vob");

var conversionOptions = new ConversionOptions
{
    Target = Target.DVD, 
    TargetStandard = TargetStandard.PAL
};

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
ffmpeg.Convert(inputFile, outputFile, conversionOptions);

Transcoding options FLV to MP4

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"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 FFmpeg.NET.Engine.FFmpeg();
ffmpeg.Convert(inputFile, outputFile, conversionOptions);

Cut video down to smaller length

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_ExtractedVideo.flv");

var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
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));
ffmpeg.Convert(inputFile, outputFile, options);

Subscribe to events

public void StartConverting()
{
    var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
    var outputFile = new MediaFile (@"C:\Path\To_Save_New_Video.mp4");    

    var ffmpeg = new FFmpeg.NET.Engine.FFmpeg();
    ffmpeg.ConvertProgressEvent += ConvertProgressEvent;
    ffmpeg.ConversionCompleteEvent += ConversionCompleteEvent;
    ffmpeg.Convert(inputFile, outputFile);
}

private void ConvertProgressEvent(object sender, ConvertProgressEventArgs e)
{
    Console.WriteLine("\n------------\nConverting...\n------------");
    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("SizeKb: {0}", e.SizeKb);
    Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);
}

private void ConversionCompleteEvent(object sender, ConversionCompleteEventArgs e)
{
    Console.WriteLine("\n------------\nConversion complete!\n------------");
    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("SizeKb: {0}", e.SizeKb);
    Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);
}

Licensing

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.4.0 30 11/15/2019
3.3.3 3,879 5/1/2019
3.3.2 111 4/30/2019
3.3.1 116 4/28/2019
3.3.0 149 4/26/2019
3.2.0 94 4/26/2019
3.1.0 1,439 11/20/2018
3.0.0 146 11/20/2018
2.1.0 313 11/19/2018
2.0.0 175 11/19/2018
1.1.9 207 11/15/2018
1.1.8 369 9/17/2018
1.0.0.1 693 5/26/2018
1.0.0 230 5/26/2018
Show less