Gerardo Hernandez
Gerardo Hernandez

Reputation: 2059

How to enable hardware-accelerated decoding in libVLC?

I am receiving multiple x264 RTSP streams and I am decoding them using libVLC and I would like to use hardware acceleration for the task.

If I use the VLC player itself on Windows, I can choose "DirectX Video Acceleration (DXVA) 2.0" in Simple Preferences->Input/Codecs->Hardware-accelerated decoding and I can see a significant drop in CPU utilization when compared to disabling that option.

In the C++ code, I tried to add the option "--avcodec-hw=dxva2" to the arguments of libvlc_new() but no luck, hardware acceleration does not seem to be used (I would say the decoding is 50% slower than in the player with dxva2 on)

Upvotes: 1

Views: 8409

Answers (1)

Gerardo Hernandez
Gerardo Hernandez

Reputation: 2059

Found it. The option must be passed to libvlc_media_add_option(), not libvlc_new(). Note that the option changed with different versions of the library. With VLC 2.2.1 it works for me with:

libvlc_media_add_option(m, ":avcodec-hw=dxva2");

where dxva2 stands for the DirectX decoder. In UNIX systems the value of the parameter would be different (vda or vaapi I think)

Upvotes: 8

Related Questions