⭐Please star this project if you find it useful!
- Current Status: (2017-09-12) - 2.0, codenamed Michelob is now in beta 1 (see the Releases)
- FFmpeg Version: 3.4.0 (32-bit)
- For a history of commits see the repo: https://github.com/unosquare/ffplaydotnet
FFME is a close (and I'd like to think better) drop-in replacement for Microsoft's WPF MediaElement Control. While the standard MediaElement uses DirectX (DirectShow) for media playback, FFME uses FFmpeg to read and decode audio and video. This means that for those of you who want to support stuff like HLS playback, or just don't want to go through the hassle of installing codecs on client machines, using FFME might just be the answer.
FFME provides multiple improvements over the standard MediaElement such as:
- Fast media seeking and frame-by-frame seeking
- Properties such as Position, NaturalDuration, SpeedRatio, and Volume are all Dependency Properties!
- Additional and extended media events. Extracting video, audio and subtitle frames is very easy.
- Ability to easily apply video filtergraphs.
- Ability to extract media metadata and tech specs of a media stream (title, album, bitrate, codecs, FPS, etc).
- Ability to apply volume, balance and speed ratio to media playback.
... all in a single MediaElement control
Your help is welcome!
- I still have some items I need to address. See the issues section.
- Working on Hardware acceleration D3D 9 and D3D 11
- There currently is no support for opening capture devices such as webcams or TV cards. While this is not too hard to do, it is not (yet) implemented in this library. See issue #48
Please note that I am unable to distribute FFmpeg's binaries because I don't know if I am allowed to do so. Follow the instructions below to compile, run and test FFME. I will look into releasing a NuGet package. See issue #1
- Clone this repository.
- Download the FFmpeg win32-shared binaries from Zeranoe FFmpeg Builds.
- Extract the contents of the
zip
file you just downloaded and go to thebin
folder that got extracted. You should see 3exe
files and 8dll
files. Select and copy all of them. - Now paste all 11 files from the prior step onto a well-known folder. Take note of the full path. (I used c:\ffmpeg)
- Open the solution and set the
Unosquare.FFME.Sample
project as the startup project. You can do this by right clicking on the project and selectingSet as startup project
- Under the
Unosquare.FFME.Sample
project, locate the linepublic string FFmpegPath { get; set; } = @"C:\ffmpeg";
and replace the path so that it points to the folder where you extracted your FFmpeg binaries (dll files). - Click on
Start
to run the project. - You should see a sample media player. Click on the
Open
icon located at the bottom right and enter a URL or path to a media file. - The file or URL should play immediately, and all the properties should display to the right of the media display by clicking on the
Info
icon. - You can use the resulting compiled assembly in your project without further dependencies as FFME is entirely self-contained. The locations of the compiled FFME assembly, depending on your build configuration are either
...\ffmediaelement\Unosquare.FFME\bin\Debug\Unosquare.FFME.dll
or...\ffmediaelement\Unosquare.FFME\bin\Release\Unosquare.FFME.dll
Remember: The Unosquare.FFME.Sample provides a reference implementation of usage
- Create a new WPF application
- Add a reference to
Unosquare.FFME.dll
- In your
MainForm.xaml
, add the namespace:xmlns:ffme="clr-namespace:Unosquare.FFME;assembly=Unosquare.FFME"
- Finally, create an instance of the FFME control in your
MainForm.xaml
as follows:<ffme:MediaElement x:Name="MediaEl" Background="Gray" LoadedBehavior="Play" UnloadedBehavior="Manual" />
In no particular order
- To the FFmpeg team for making the Swiss Army Knife of media. I encourage you to donate to them.
- To Kyle Schwarz for creating and making Zeranoe FFmpeg builds available to everyone.
- To the NAudio team for making the best audio library out there for .NET -- one day I will contribute some improvements I have noticed they need.
- To Ruslan Balanukhin for his FFmpeg interop bindings generator tool: FFmpeg.AutoGen.
- To Martin Bohme for his tutorial on creating a video player with FFmpeg.
- To Barry Mieny for his beautiful FFmpeg logo
- Please refer to the LICENSE file for more information.