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 a separate process (via System.Diagnostics.Process) and your .NET app remains fully isolated.
  • 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# / NET8):
    • 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)
    • DemoMvc: 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 Online payment methods
  • 3 Download the package
Video Converter provides C# API for executing FFMpeg process from .NET applications. FFMpeg can convert video files, resize/cut/combine video, get video thumbnail, capture screen, create video from images, decode video frames as bitmaps etc.

how to use

  1. Add a reference to 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. Feel free to contact us
    in case of any questions.
    What's next:

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 non-SaaS .NET apps that have only one single-server production deployment.

A commercial license (included into "enterprise source code" pack) is required for:
  • Applications for external redistribution (ISV), multiple deployments
  • Usage in SaaS apps
  • Non-Windows deployments that are supported with NReco.VideoConverter.LT nuget
  • Email support/assistance (support is NOT available for free users)
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 executes FFMpeg in a separate process (via System.Diagnostics.Process API) and your hosting environment/platform should allow that. This might be not possible in the following cases:
  • partial-trust environments: most shared ASP.NET hostings
  • Azure Apps on 'shared' plan. Azure Apps with VM-based plan ('Basic' or higher) can run tasks automated with VideoConverter.
  • UWP Apps (System.Diagnostics.Process API is not available).
VideoConverter works fine with Azure VM instances (Web Role, Worker Role, Azure WebJobs).

Linux/MacOS
Non-Windows deployments are supported with NReco.VideoConverter.LT nuget: this is a version without ffmpeg.exe, it expects that ffmpeg is deployed separately and suitable for Linux/Docker or MacOS, or if you want to use a specific ffmpeg version/build.

NET8+
Starting from version 1.2.0 you can use NReco.VideoConverter nuget in modern .NET apps and get leverages of simplified deployment (no need to deploy ffmpeg.exe separately). This nuget can be used only for Windows deployments.
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

2023 Apr 13 v.1.2.1:
  • fixed issue that can occur when FFMpegConverter.Stop method is called (NullReferenceException at AsyncStreamReader.WaitUtilEOF)
2023 Jan 18 v.1.2.0:
  • added netstandard2.0 build for NReco.VideoConverter nuget (includes ffmpeg.exe); now it can be used in NET6/NET8/.NET Core apps with free offering! (Windows deployments only)
  • ffmpeg.exe updated to the latest stable release 5.1.2 (x64 "essentials" build from https://www.gyan.dev/ffmpeg/builds/)
  • now relative paths (both for input/output) are resolved in respect to the current working directory, not to ffmpeg location (FFMpegToolPath)
  • fixed an issue when FFMpegException didn't reflect the last error line from ffmpeg console log output
2020 Jan 23 v.1.1.4:
  • FFMpeg updated to v.4.2.1
  • added GetVideoThumbnail overloads that accept ConvertSettings (to pass any custom ffmpeg options)
  • fixed (rare) InvalidOperationException issue related to cleanup of FFMpeg Process
  • fixed issue with FFMpegInput.Format in ConvertMedia overload that accepts FFMpegInput[]
2018 Jun 12 v.1.1.3:
  • FFMpeg updated to v.4.0
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.

  • HTML-to-PDF Generator

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