Video Converter for .NET FFMpeg C# wrapper


features C# video library

  • FFMpeg .NET wrapper: convert (encode,decode) almost all known video and audio formats (mp4,mp3,h264,wmv,wav,avi,flv,mov,mkv,webm,ogg and many others)
  • no memory leaks: ffmpeg is executed in separate process
  • all ffmpeg command-line options are supported
  • can resize/crop/cut/split/merge video files, combine video and audio from different files, transcode live video stream from C# Stream input (Webcam, RTSP URL, file) to C# Stream output (streaming server URL, file)
  • easy to use video conversion .NET library: all you need is one assembly (FFMpeg is embedded into DLL and extracted on first use)
  • Usage examples (C#):
    • Concat: merge several videos into one resulting file (with complex filter and 'concat' demuxer)
    • CutCropResize: code snippets to cut/crop/resize videos
    • VideoWatermark: apply watermark to the video (PNG image or just a text)
    • DemoWebForms: Convert any video file to MP4/FLV, extract video thumbnail, apply video watermark image (online demo code)
    • ConvertProgressWinForms: convert video with progress bar in a separate thread (WinForm app)
    • LiveStreamMvc: on-the-fly live stream transcoding for HTML5 video (ASP.NET MVC app)
    • LiveStreamRecognition: decode h264 stream and get frames as Bitmaps for further processing (for video recognition or extracting sequence of video thumbnails for every minute) as C# Bitmap objects (console app)
    • LiveStreamFromImages: encode live video stream from images (Bitmap objects, without temp files). Can be used for creating animated GIFs.
    • Rotate: detect video clip orientation and perform necessary rotation
    • ScreenCapture: record desktop (with mouse moves) and save as mp4 video + softly stop encoding process by sending Ctrl+C signal

download and pricing

quick purchase process

  • 1 Choose a package
  • 2 Pay online 2Checkout.com is a worldwide leader in online payment services
  • 3 Download the package
Video Converter provides C# API for executing FFMpeg process from .NET applications. It can convert media files, cut or combine video, get video thumbnail, capture screen, create video from images, decode video frames as bitmaps etc.

how to use

  1. Download package and add reference to NReco.VideoConverter.dll assembly OR install NReco.VideoConverter nuget package
  2. Convert video to MP4 by executing FFMpeg process with one line of C# code:
    var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
    ffMpeg.ConvertMedia(pathToVideoFile, "video.mp4", Format.mp4);
  3. Get video thumbnail (C#):
    ffMpeg.GetVideoThumbnail(pathToVideoFile, "video_thumbnail.jpg");
  4. That's all! Check out online documentation if you need to specify extra converter settings (formats, codecs etc).
Have a question? Feel free to ask.

online video converter demo

Note: video upload and conversion may take some time (up to 2 minutes).
Convert video   Watermark video   Get video thumbnail

frequently asked questions

VideoConverter can be used for FREE in single-deployment projects (websites, intranet/extranet) or applications for company's internal business purposes (redistributed only internally inside the company).

Commercial license (included into enterprise pack) is required for:
  • Applications for external redistribution (ISV)
  • SaaS deployments

Also you may purchase standard commercial package if you need:
  • LT build for Mono/.NET Core
  • email support/assistance (note that support is NOT available for free users)
  • advanced usage examples
VideoConverter is based on FFMpeg tool; this tool supports almost all known video and audio formats (detailed list of supported formats: ffmpeg.exe -formats and ffmpeg.exe -codecs).
VideoConverter invokes FFMpeg in a separate process (with System.Diagnostics.Process) and your project environment/platform should allow that. This might be not possible in the following cases:
  • partial-trust environments: most shared ASP.NET hostings
  • Azure Apps (WebSites) -- note that Azure WebJobs is supported
  • UWP Apps -- they just don't have System.Diagnostics.Process API used by VideoConverter. You may try Microsoft's FFMpeg interop library for Win10/WinPhone8.1 apps (FFMpeg GPL codecs are not available for non-GPL apps in this case).
VideoConverter works fine with Azure VM instances (Web Role, Worker Role, Azure WebJobs).
Both .NET 2.0 and 4.0 runtimes are supported.

Linux/MacOS + MONO
Default build (NReco.VideoConverter.dll) embeds ffmpeg.exe (windows x86) and as result it will not work under non-windows platforms (like MONO/Linux).
Special LT build NReco.VideoConverter.LT.dll was introduced to overcome this limitation: it doesn't embed ffmpeg.exe and you can use any ffmpeg binaries you need (Linux, OS-X or custom build).

.NET Core
Commercial package includes LT build compiled for .NET Standards 1.5 that can be used from .NET Core applications.
Note that you should deploy ffmpeg binaries for your target platform(s) (Windows, Linux or OS X) with your .NET Core app.
The following code snippet illustrates how to do that with VideoConverter:
var ffmpeg = new NReco.VideoConverter.FFMpegConverter();
ffmpeg.ConvertMedia(
  new [] {
    new FFMpegInput("video.mp4"),
	new FFMpegInput("audio.mp3")
  }, "result.mp4", null, 
  new ConvertSettings() {
    AudioCodec = "copy", // or audio codec for re-encoding 
	VideoCodec = "copy", // or video codec for re-encoding
	CustomOutputArgs = " -map 0:v:0 -map 1:a:0 "
});
Normally VideoConverter works with files but some tasks require real-time processing of media stream (usually this is video/audio broadcast or webcam stream). Live stream data is processed as it comes; its duration is not known in advance.

NOTE: not all media formats could be used with as live streams (for example, MP4 format can be processed only as file).
FFMpeg can generate video from files with special image2 demuxer and this can be achieved with VideoCoverter. As alternative VideoConverter can generate live video stream from Bitmap objects (package includes special example for this use case).
Yes it is possible to consume live stream and get each frame as Bitmap in C# code for further real-time processing (video recognition, for instance). Package includes special example for this use case.
Yes you can use VideoConverter for creating animated GIFs from existing video clip or bitmaps (images):
var ffmpeg = new FFMpegConverter();
ffmpeg.ConvertMedia("your_clip.mp4", null, "result.gif", null, new ConvertSettings() );
To avoid huge size of resulting GIF file better to descrease frame rate and resulting GIF frame size. Also note that GIF image can have only 256 (!) colors; this means that if your video has a lot of different colours it might look weird when converted to GIF. You can get nice-looking GIFs using 2-pass approach that generates optimal palette for GIF file first.

what's new

2017 Jan 14 v.1.1.2:
  • FFMpeg updated to v.3.2.2
  • ConvertLiveMediaTask.Stop uses only 'q' command if possible (CTRL+C method not used because of instability)
  • Fixed IOException issue thrown by ConvertLiveMedia
  • added FFMpegConverter.LogLevel property
  • added FFMpegConverter.ExtractFFmpeg() method (forces extraction of ffmpeg binaries)
2016 Jul 04 v.1.1.1:
  • FFMpegConverter.Stop switched from sending CTRL+C to ffmpeg console to 'q' command written to stdin: this approach is more stable and compatible with .NET Core
  • Fixed issue with NullReferenceException from Process.WaitForExit (thrown when Stop method is called from another thread)
  • added NReco.VideoConverter.LT build for NET Standards 1.5 (can be used from .NET Core apps)
2016 Apr 19 v.1.1.0:
  • FFMpeg updated to v.3.0.1
  • added FFMpegConverter.ConvertMedia overload that accepts several FFMpeg inputs -- it is useful for appending audio to video, applying watermark to video, video concatenation (with concat filter)
  • added CutCropResize example
  • added VideoWatermark example (apply image or text)
2015 Dec 14 v.1.0.9:
  • now LogReceived event works for ConvertLiveMedia (useful for debugging purposes)
  • now ConvertProgress event works for ConvertLiveMedia
  • FFMpeg updated to v.2.8.3
  • added LT build: VideoConverter without embedded ffmpeg.exe (commercial package)
2015 Sep 22 v.1.0.8:
  • fixed issue with FFMpegConverter.Stop method (FreeConsole leads to WinForms/WPF app crash - workaround was added)
  • added FFMpegProcessUser property (run ffmpeg.exe process under specified user)
  • fixed issue: FFMpegProcessPriority ignored for ConvertLiveMedia
  • now NReco.VideoConverter is signed (strongly named) assembly
2015 Aug 07 v.1.0.7:
  • FFMpeg updated to v.2.7 release (Jun 12 2015)
  • fixed null references exception when FFMpegConverter.Stop is called (non-console apps)
2015 May 14 v.1.0.6:
  • embedded FFMpeg tool updated to v.2.6.2 (build May 13 2015)
  • fixed incorrect ConvertProgress duration calculation when ConvertSettings.Seek and/or ConvertSettings.MaxDuration specified
  • added FFMpegConverter.Stop method (+ overload for ConvertLiveMediaTask.Stop) that softly stops ffmpeg process (by sending Ctrl+C signal)
2015 Jan 21 v.1.0.5:
  • upgrade FFMpeg to v.2.5 (build Jan 21 2015) that fixes freezing for some video
  • added correct handling of ConvertProgress event for ConcatMedia method
  • added ExecutionTimeout property (stop conversion process if the timeout expires; useful in some cases to prevent server overload)
2014 Nov 02 v.1.0.4: upgrade FFMpeg to version built on Nov 02 2014 + minor fix for convert progress event (in some cases it always returns zero progress).
2014 Aug 24 v.1.0.3:
  • fix: setting process priority (Normal by default) prevents VideoConverter from working in Azure WebJobs environment.
  • fix: temp file is not removed in ConvertMedia overload that copies conversion result to Stream
  • added simple image watermarking example with FFMpeg filter graph (DemoWebForms)
2014 Aug 04 v.1.0.2: upgrade FFMpeg to version built on Jul 28 2014.
2014 May 12 v.1.0.1: added Invoke method for untypical ffmpeg usage or complicated command line arguments.
2014 Apr 16 Added LogReceived event (enables FFMpeg log analysis). Added example that detects clip orientation and performs video rotation.
2014 Apr 08 Added ConvertLiveMedia overload for writing result directly to file (useful for grabbing live stream to MP4 format)
2014 Mar 11 Bugfix for issue with live stream conversion (freezing)
2014 Mar 08 ConvertLiveMedia: added support for FFMpeg input sources (URL/path to file, HTTP/UDP/TCP endpoints).
2014 Feb 23 Example for generating video stream from Bitmap images
2014 Feb 17 Example for grabbing live stream frames as Bitmap images
2014 Feb 02 VideoConverter is available as NuGet package
2014 Jan 14 Added FFMpegProcessPriority property (useful to avoid resources overuse at webserver)
2013 Dec 27 Bugfixes: filename with space, issue when ConvertMedia is called simultaneously from different threads, avoid hang up from unit testing environment like NUnit
2013 Dec 07 API documentation (generated from XML-comments) is now availabe
2013 Nov 20 Added ConvertProgress event and progress bar example
2013 Nov 13 Example for live stream conversion
2013 Oct 23 Added media concatentation support (ConcatMedia method)
2013 Oct 21 Added live stream conversion support (ConvertLiveMedia method and ConvertLiveMediaTask class)
2013 Sep 08 Initial VideoConverter release

more components

  • Image Generator

    .NET wrapper WkHtmlToImage utility that generate pretty-looking images by HTML layout.

  • PhantomJS .NET Wrapper

    NReco.PhantomJS is a .NET wrapper for running PhantomJS from C#/.NET code (headless WebKit browser).

  • HTML-to-PDF Generator

    .NET wrapper for WkHtmlToPdf utility that generates PDF reports by HTML template.

  • PivotData Toolkit for .NET

    .NET components for manipulating multidimensional dataset (in-memory data cube) without OLAP server, aggregating huge datasets, calculating data for pivot table / chart reports, ASP.NET pivot table builder control.