(This article also published in my public number "dotnet daily Essence article", Welcome to the right QR code to pay attention to. )
Preface: It's difficult to develop a media player that supports multiple formats on a Windows phone because you can't take advantage of an open source library like Ffmpege. But right now, Microsoft has provided an open source Ffmpeginterop to solve this problem.
Due to the limitations of the WINRT and Windows Phone platforms, the above app can only play several formats supported by the built-in multimedia player (such as wmv,mp4, etc.), although these formats still satisfy most cases. But if you're going to develop a format that supports a more comprehensive player (or if your software intends to play some extra formats, such as MKV, FLV, and MOV), then it's a bit of a hassle, because some of the common open source multimedia libraries can't be used directly. Even the famous software such as VLC has been slow to launch WP version.
Microsoft has released a series of compilation instructions to build and WINRT compatible ffmpeg. However, this can lead to performance loss. To solve this problem, Microsoft recently released an open source library called Ffmpeginterop on GitHub to solve this problem. This open source Library uses Ffmpege to process media content, but playback uses the Windows Media Framework. This way you can get better performance because the Windows Media Framework can take advantage of hardware acceleration. Microsoft has also released a sample Media Player app written in C #, C + +, and JavaScript.
The general usage is:
- Creates a Ffmpeginterop object that is inserted into the XAML MediaElement object or in the Winjs HTML5 video component
- Use Fileopenpicker to open a local file as a pass-through to Ffmpeginterop
The C # code for the above steps is similar to the following:
1://Instantiate FFmpeg object and pass the stream from opened file
2: irandomaccessstream readstream = await file. OpenAsync (Fileaccessmode.read);
3:false);
4:
5://Pass Mediastreamsource to Media Element
6: Mediaelement.setmediastreamsource (Ffmpegmss.getmediastreamsource ());
More detailed usage can be understood by "reading the original". The GitHub address of the item can also be found from the original address.
(in particular, Microsoft's homepage on GitHub also lists a lot of open-source projects, a treasure that cannot be missed.) )
Original address: http://blogs.windows.com/buildingapps/2015/06/05/using-ffmpeg-in-windows-applications/
Windows and Windows Phone apps can finally use FFmpeg.