I said I didn't think we were far away from cracking this nut, and I'm please to say that I think we are there...
I have now tweaked a script that allows the building of an ffmpeg.exe within Windows which includes the option to encode to h264 using Intel QuickSync GPU transcoding.
If you'd like to try it out you can either follow the usage instructions for the build script and build the .exe yourself, or download a pre-compiled ffmpeg.exe from the releases section.
If you'd like to try it out, you need to specify the video codec h264_qsv in order to use QuickSync rather than x264, for example:
ffmpeg -i "input.mp4" -b:v 4000k -vcodec h264_qsv "output.mp4"
You should be able to replace the existing ffmpeg.exe within the MediaBrowser Server installation and everything should just continue to work as before (since I have tried to compile ffmpeg with all the libraries that MediaBrowser needs to use).
Because MediaBrowser currently runs ffmpeg with -vcodec libx264 a change will need to be made to the MediaBrowser code to switch this to -vcodec h264_qsv
Another issue is that MediaBrowser also favours WEBM for web browser streaming which does not use the h264 codec, as a result it will never be possible to use QuickSync to improve performance. However, it should be possible to tweak MediaBrowser so that rather than WEBM, we use h264 MP4's instead. Technically this isn't as HTML5 friendly as WEBM, but most browsers do support MP4 video natively, so this might be a sacrifice worth making to take advantage of GPU transcoing.
It seems that it is BaseStreamingService.cs (and possibly other front-end files) that will need to be updated to enable QuickSync support from within MediaBrowser. Having spent so long trying to get ffmpeg working with QuickSync I now realise that making these changes to MediaBrowser is a little bit beyond me, so I was wondering if any of the MediaBrowser team are able to take this on?
I guess we'd need to add two checkboxes to the MediaBrowser server GUI...
- [ ] Use Intel QuickSync when transcoding to h264 video
- [ ] Use h264 (MP4) instead of VP8 (WEBM) for web streaming clients
It would be great if you could try out this ffmpeg build and let me know how it works for you and if any of the MediaBrowser guys could provide feedback on the possibility of making this alterations to the ffmpeg command line.
I need to thank the drocon11/ffmpeg-qsv, lu-zero/mfx_dispatch and jb-alvarado/media-autobuild_suite projects which are essentially the projects I have combined to get the build script working.
All of the code that goes in to generating the ffmpeg.exe is GPL, so the compiled .exe can be distributed without any problems - so it should be possible for it to truly be a drop-in replacement.
This all works only on Windows. Linux support is probably not far away, but there are a couple of additional hardware acceleration libraries which are required and I don't have the Linux skills to make this work (so the changes to the server GUI would have to be for Windows users only).