Using FFmpeg in Windows Applications

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 Instructions

In 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 Object
FFmpegInterop 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 Samples
Also 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:

  1. Create a FFmpegInterop object that plugs easily into a XAML MediaElement or WinJS HTML5 Video component
  2. Open a local file using FileOpenPicker and pass it as a stream to FFmpegInterop
  3. 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: https://github.com/Microsoft/FFmpegInterop

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:



Source: http://blogs.windows.com/buildingapps/2015/06/05/using-ffmpeg-in-windows-applications/
 
Better late than never I guess. Been using it for years through third party codec packages.
 

My Computer

System One

  • OS
    Windows 8.1 Pro 64-bit
    Computer type
    Laptop
    System Manufacturer/Model
    Acer V3 771G-6443
    CPU
    i5-3230m
    Motherboard
    Acer VA70_HC (U3E1)
    Memory
    8GB DDR3 PC3-12800 (800 MHz)
    Graphics Card(s)
    HD4000 + GeForce GT 730M
    Sound Card
    Realtek High Definition Audio
    Monitor(s) Displays
    17" Generic PnP Display on Intel HD Graphics 4000
    Screen Resolution
    1600x900 pixels
    Hard Drives
    Samsung SSD 850 EVO 250 GB
    ADATA SSD SP900 128GB
    PSU
    90 watt brick
    Mouse
    Bluetooth
    Antivirus
    Comodo
    Other Info
    Asus RT-AC56R dual-band WRT router (Merlin firmware). Intel 7260.HMWWB.R dual-band ac wireless adapter.
Back
Top