Skip to content

mrapitis/FFmpegInteropX

 
 

Repository files navigation

FFmpegInteropX library for Windows

This project is licensed under the Apache 2.0 License

Welcome to FFmpegInteropX

FFmpegInteropX is an open-source project that aims to provide an easy way to use FFmpeg in Windows 10 UWP Apps. This allows you to decode a lot of formats that are not natively supported on Windows 10.

FFmpegInteropX is a much improved fork of the original Microsoft project.

Latest Releases:

Some of the important improvements:

  • NuGet packages!!
  • Multiple audio stream support
  • Subtitle support, including external subtitle files
  • Audio effects (special thanks to mcosmin222!)
  • Stream information retrieval (name, language, format, etc)
  • Passthrough of the following video formats for hardware decoding
    • HEVC
    • VC1 (Used in VC1 Advanced Profile)
    • WMV3 (Used in WMV9 and VC1 Simple and Main Profile)
    • MPEG2 (Requires "MPEG-2 Video Extensions" from Windows Store)
    • VP9 (Requires "VP9 Video Extensions" from Windows Store)
  • Major performance improvements (zero-copy data handling in all important areas)
  • Frame grabber support
  • Chapter information support
  • API improvements
  • Include zlib and bzlib libraries into ffmpeg for full MKV subtitle support
  • Include iconv for character encoding conversion
  • Include libxml2 for DASH streaming support
  • Lots of bug fixes

Other changes:

  • Support for Windows 8.x and Windows Phone 8.x has been dropped
  • Visual Studio 2015 support has been dropped

How to work with FFmpegInteropX

We have switched from manual builds to providing NuGet packages. There are two packages:

  • FFmpegInteropX

    • The library itself, referenced by app project files
    • Has a dependency on FFmpegInteropX.FFmpegUWP, which contains the actual FFmpeg build
  • FFmpegInteropX.FFmpegUWP

    • Our official FFmpeg build for the UWP platform
    • Customized and tested for use with FFmpegInteropX
    • Includes FFFmpeg dll files, libs, includes and license files
    • Two purposes:
      • Provide runtime dependencies (dlls) for apps
      • Provide build dependencies for our library

The easiest way to work with FFmpegInteropX is to add both NuGet packages to your app. This allows full usage of all features, without checking out the repo or installing build tools.

Advanced users and library developers: If you want to be able to debug into FFmpegInteropX right from your app, or to work on the library, you need to clone this repository. Instead of adding the FFmpegInteropX NuGet package to your app, you can directly add the FFmpegInterop\FFmpegInterop.vcxproj project file to your app solution (it does not matter where the FFmpegInteropX folder is located). Then in your main app project, add a reference to the FFmpegInterop project. Now you have all the sources directly in your app solution and can debug and enhance the lib.

Full blown: If needed, you can even supply your own custom FFmpeg build to replace our FFmpegInteropX.FFmpegUWP NuGet package.

Check out the build instructions if you want to manually build FFmpgeInteropX or FFmpeg itself.

Using the FFmpegInteropX libraray

Using the FFmpegInteropMSS object is fairly straightforward and can be observed from the sample applications provided.

  1. Get an IRandomAccessStream for the media you want to playback.
  2. Create a new FFmpegInteropMSS object using FFmpegInteropMSS.CreateFromStreamAsync() passing it the stream and optionally a config class instance.
  3. Get the MediaPlaybackItem from the Interop object by invoking CreateMediaPlaybackItem()
  4. Assign the MediaPlaybackItem to your MediaPlayer or MediaElement for playback.

Important: Store the FFmpegInteropMSS instance e.g. in a local field, as long as playback is running. If the object is collected by the GC during playback, playback will stop with an error.

Use FFmepgInteropMSS.CreateFromUriAsync() to create a MediaStreamSource on a streaming source (shoutcast for example).

You can use FFmpegInteropMSS.GetMediaStreamSource() to get the MediaStreamSource like in the original version of the library. But when using MediaStreamSource, you won't get subtitles. Subtitle support requires using the MediaPlaybackItem!

You can add a call to FFmpegVersionInfo.CheckRecommendedVersion() in your app startup code. This will raise an exception if you are using the lib with a version lower than the recommended version. This can help remind you to update ffmpeg after you updated FFmpegInterop.

Call FrameGrabber.CreateFromStreamAsync() to grab one or more frames from a video file.

Subtitle Support

FFmpegInterop will automatically load and use all embedded subtitles, supporting all formats through ffmpeg. You have to use the MediaPlaybackItem returned from the MSS object. Then subtitles can be selected from MediaElement's transport controls.

You can also add external subtitle files by using FFmpegInteropMSS.AddExternalSubtitleAsync(), even during playback. See the sample apps for reference. All ffmpeg subtitle formats are supported as external files, except for the two-file "sub/idx" (DVD) format.

Some external text subtitle files are stored with ANSI encoding instead of UTF8 (which is required by ffmpeg). FFmpegInterop can do an automatic conversion to UTF8. This is enabled by default in the config class and will use the system's active codepage by default. You can change the behavior by changing AutoCorrectAnsiSubtitles and AnsiSubtitleEncoding parameters in the config class. Codepage 0 is the system's active codepage.

Note: If your app uses multiple windows using CoreApplication.CreateNewView(), then you must create the FFmpegInteropMSS object on the thread of the window where the video is to be shown. Otherwise, subtitles will flicker.

FFmpegUniversal

A branch exists which makes FFmpegInterop compatible with FFmpegUniversal builds. It is a project which merges the individual ffmpeg dlls into one single file. This can make deployment easier. Check FFmpegUniversal for more details.

Credits / contributors

Thank you also to Microsoft and the team who developed the original library!

Your feedback is appreciated!

About

FFmpeg decoding library for Windows 10 UWP Apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 87.5%
  • C# 6.3%
  • PowerShell 4.6%
  • Other 1.6%