DEV Community

John Stamatakis
John Stamatakis

Posted on

How to perform Hardware (GPU) Video Acceleration in .NET (based on FFmpeg & SharpDX)

As I've not found any similar resources / documentation I've decided to write my own tutorial / project for how to perform Hardware (GPU) Video Acceleration without using CPU or even RAM at all (focusing on Windows platforms and DirectX).

I've been using on my Video Player project FFmpeg 's Hardware Acceleration for decoding already, but that was not the heavy part for CPU/RAM as the Video Processing is (converting NV12 texture2D to RGBA - I was doing that with ffmpeg 's sws_scale).

After straggling by reading few resources and large low level code I've managed to perform it by grabbing ID3D11Texture2D from ffmpeg's decoder and transfer it to mine ID3D11Device (with the help of SharpDX).

Finally, as I had access to that texture in GPU i called DirectX VideoProcessorBlt to convert it without bringing it back in CPU.

You will be able to find a Sample .NET CSharp Project and more details at my github -> https://github.com/SuRGeoNix/MediaRouter/tree/master/Tutorials/VideoPlayer_HWAcceleration

Top comments (0)