It is important to Microsoft that developers can leverage open-source software when building apps for Windows. As part of this effort we’re very pleased to announce FFmpeg support for Window 8.1, Windows Phone 8.1, and Windows 10 applications.
What is FFmpeg?FFmpeg is a free, open-source multimedia framework that includes a set of tools which can be used by end users for transcoding, streaming, and playing, as well as a set of libraries for developers to use in applications. These libraries are valuable to developers as they add support for virtually all media formats including .mkv, .flv, and .mov. Projects that use FFmpeg libraries include Google Chrome, VLC, and many more.
What’s new?We have released a set of Compilation Instructions for a WinRT compatible build of FFmpeg. Typically, after including FFmpeg libraries, developers have to go through the costly effort of rendering audio and video frames themselves. To solve this issue, we have released an open-source project, FFmpegInterop library for Windows. This project includes the FFmpegInterop WinRT component which processes media with FFmpeg and then leverages the Windows Media Framework for playback. This approach works well because the Windows Media Framework automatically renders and synchronizes media samples while reaping the benefits of hardware acceleration.
To demonstrate this we have also included three sample Media Player applications in C#, C++, and JavaScript.
Compilation InstructionsIn order to leverage the powerful and diverse multimedia features of FFmpeg, we have contributed a set of compilation instructions for Windows 8.1, Windows Phone 8.1, and Windows 10 applications. After following the compilation instructions, developers can include FFmpeg libraries in their applications, enabling apps to play or stream almost any video format.
FFmpegInterop ObjectFFmpegInterop is a WindowsRuntime Component that produces a MediaStreamSource which can be assigned to a XAML MediaElement or HTML5 video component for playback of any media file format supported by FFmpeg. This FFmpegInterop component can be used as a template to utilize further functionality of the FFmpeg libraries. Moreover the FFmpegInterop object can be accessed by multiple programming languages including C#, CX/C++, and JavaScript.
Media Player Application SamplesAlso included with the FFmpegInterop library for Windows are sample Media Player applications in C#, C++, and JavaScript for Windows 8.1, Windows Phone 8.1, and Windows 10. They demonstrate how to achieve the following:
- Create a FFmpegInterop object that plugs easily into a XAML MediaElement or WinJS HTML5 Video component
- Open a local file using FileOpenPicker and pass it as a stream to FFmpegInterop
- Project the API to the different Windows Runtime languages (CX/C++, C#, and JavaScript)
Example:Using the FFmpeg MediaStreamSource Object in a XAML Media Element.
C++Code:
// Instantiate FFmpeg object and pass the stream from opened file IRandomAccessStream^ readStream = stream.get(); FFmpegMSS = FFmpegInteropMSS::CreateFFmpegInteropMSSFromStream(readStream, false, false); // Pass MediaStreamSource to Media Element mediaElement->SetMediaStreamSource(FFmpegMSS->GetMediaStreamSource);
C#Code:
// Instantiate FFmpeg object and pass the stream from opened file IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read); FFmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromStream(readStream, false, false); // Pass MediaStreamSource to Media Element mediaElement.SetMediaStreamSource(mss);
To submit feedback, pull-requests, or issues, please check out the GitHub repo:
If you have a suggestion for other open source projects that would help you make great applications, please let us know in the comments.
For more information about Microsoft’s involvement with open source check out these sites: