CraftingDragon007.MediaToolkit 2.0.1

dotnet add package CraftingDragon007.MediaToolkit --version 2.0.1
NuGet\Install-Package CraftingDragon007.MediaToolkit -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CraftingDragon007.MediaToolkit" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CraftingDragon007.MediaToolkit --version 2.0.1
#r "nuget: CraftingDragon007.MediaToolkit, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CraftingDragon007.MediaToolkit as a Cake Addin
#addin nuget:?package=CraftingDragon007.MediaToolkit&version=2.0.1

// Install CraftingDragon007.MediaToolkit as a Cake Tool
#tool nuget:?package=CraftingDragon007.MediaToolkit&version=2.0.1

MediaToolkit

MediaToolkit 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, MediaToolkit 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.

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 MediaToolkit from NuGet using the Package Manager Console with the following command (or search on NuGet MediaToolkit)

PM> Install-Package MediaToolkit

Samples

Grab thumbnail from a video

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_Image.jpg"};

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

Retrieve metadata

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};

using (var engine = new Engine())
{
    engine.GetMetadata(inputFile);
}

Console.WriteLine(inputFile.Metadata.Duration);

Basic conversion

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_New_Video.mp4"};

using (var engine = new Engine())
{
    engine.Convert(inputFile, outputFile);
}

Convert Flash video to DVD

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_New_DVD.vob"};

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

using (var engine = new Engine())
{
    engine.Convert(inputFile, outputFile, conversionOptions);
}

Transcoding options FLV to MP4

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"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
};

using (var engine = new Engine())
{
    engine.Convert(inputFile, outputFile, conversionOptions);
}

Cut video down to smaller length

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_ExtractedVideo.flv"};

using (var engine = new Engine())
{
    engine.GetMetadata(inputFile);

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

    engine.Convert(inputFile, outputFile, options);
}

Subscribe to events

public void StartConverting()
{
    var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
    var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_New_Video.mp4"};
    
    using (var engine = new Engine())
    {
        engine.ConvertProgressEvent += ConvertProgressEvent;
        engine.ConversionCompleteEvent += engine_ConversionCompleteEvent;
        engine.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 engine_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

Product 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 494 11/27/2022
2.0.0 381 6/22/2022