Saturday, March 4, 2017

Playing video in a Visual Studio Solution/Project using the FFmpegInterop




The following relates to my experiencing of tireless trial and error of finally getting the FFmpegInterop building and running as described here...

https://github.com/Microsoft/FFmpegInterop in Visual Studio 2017

I'm running Windows 10.
My tests were performed with VisualStudio 2015 and 2017 community editions



I like to think of the process like this...

  1. Get a copy of FFmpegInterop
  2. Getting a compatible build of ffmpeg
  3. Combine the two into one folder structure
  4. Load up the FFmpegInterop Solution/Project in VS 2015 edition. Build and run
  5. Copy the FFmpegInterop folder from Visual Studio 2015 projects folder and place into the VS 2017 projects folder
  6. Load build and run





FFmpegInterop
16 March 2017:
Head over to...
https://github.com/Microsoft/FFmpegInterop

Have a read. Check this is actually something you want.

Grab a copy of the project file.
I recommend putting it in a safe place such as your personal archives for future use. Put it somewhere where you will not mess with it's data. 
Somewhere for safe keeping!

Now grab a copy of the above file and  place it on your desktop.
Extract the file.
Inside the extracted folder is another folder of the same name. 
I recommend taking a copy of this internal folder (of the same name) and putting it in a safe place such as your personal archives for future use. Somewhere for safe keeping.



Compatible build of FFmpeg

16 March 2017
As per the prerequisites as noted on the FFmpegInterop download page, we will need a compatible build of FFmpeg for this to work.

So using git, grab yourself a copy of the latest ffmpeg source code using git...



git clone git://source.ffmpeg.org/ffmpeg.git
You will end up with a folder called ffmpeg

As always, I recommend putting a copy of this away in a safe place so you can replicate your success with good data in the future.

Now head to...
https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT

and simply follow the instructions.
There's a lot there. Follow the instructions very carefully. Take your time!

During my time attempting this, there were a couple of things that tripped me up.


Trip-up 1...

You will need Visual Studio 2015 with Cross Tool launchers in your Windows start menu.
I had an install of Visual Studio 2015 that did not provide the launching of (in my case....  
VS2015 x86 x64 Cross Tools Command Prompt
from the Windows Start menu

So this was a little hit-and-miss for a while but I finally found an install that gave me...
VS2015 x86 x64 Cross Tools Command Prompt
See the picture below. Hunt around for the download that provides the many  Cross Tools in your Start menu.



My download file was called...
vs_community_ENU.exe
I'm sorry but I can't recall where I got this download from.


Trip-up 2
My Windows 10 username comprises of both my First and Last name and I had my ffmpeg source folder hanging from that. Example...

C:\Users\MyFirstName MyLastName\Documents\here

So you can see here that the path has white space in it. A successful build and compile etc will fail if you build in such a path.

----------------------

Sort out Trip-up 1 above
Regarding Trip-up 2, Just make a folder directly on your root c drive. Ive called mine...
C:\here
Grab your copy of ffmpeg and place it in the above folder. So now you'll have...
C:\here\ffmpeg

Now that the above is sorted, continue on with the instructions here...
https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT
and remember to take your time.

Once you have successfully built a compatible ffmpeg folder, put it away safe (since that was a lot of work)

------------------------------------

Get your copy of FFmpegInterop folder from your archives and place it in your VS 2015 projects folder

In the above folder should be an ffmpeg folder which should be empty.

What you want to do now is replace the ffmpeg folder with your newly built ffmpeg folder.

You can now Launch VS 2015 and load up the appropriate Windows10 or Windows8.1 solution. Set the startup project to...
MediaPlayerCS 
for c#

And build/run
It's very possible that VS will present prompts stating you need to update/convert this that and the other. just go with the flow here and accept the defaults.

Once you get success with 2015, Copy the  FFmpegInterop project folder from VS 2015 to VS 2017

Reload with VS 2017 and test

Good luck!




Findings....
Out of the box solution plays various media types straight off the hard drive no problem.
Also plays RTSP streams no problem.
Cant seem to play my IP camera http streams. With some tweaking I'm hoping to overcome this!
















No comments:

Post a Comment

Kotlin (Programming language)

Todo