Video Acceleration on Gentoo
- Posted:
2023-09-27
Over the past few months, I have found myself gradually spending more time on watching Youtube videos, both for entertainment and learning. I usually watch them on my laptop, which is equipped with an integrated GPU - AMD Radeon Vega 8. This got me thinking about how I can take advantage of it to reduce CPU load.
The media players that I use the most are Firefox and MPV (for watching downloaded Youtube videos). According to the list of video acceleration support across different applications [1], the only method supported by both of them is VA-API, which is an open source application programming interface that allows applications such as VLC media player or GStreamer to use hardware video acceleration capabilities, usually provided by the graphics processing unit (GPU) [2].
Setting up Gentoo Portage
In order to enable VA-API for an AMD GPU, the driver "radeonsi" should be added to the list of video cards [3]:
# ed /etc/portage/make.conf a VIDEO_CARDS="amdgpu radeonsi" . wq
Also, for programs/applications, such as Firefox and MPV, that support VA-API, the USE flag "vaapi" can be enabled globally [4]:
# ed /etc/portage/make.conf a USE="vaapi" . wq
Then, update the whole system to apply these changes:
# emerge -av --update --deep --newuse @world
From now on, VA-API has been enabled system-wide. let's then configure VA-API for specific programs/applications.
Configuring MPV
To enable VA-API in MPV, either add hwdec-vaapi to its configuration file, or use the option --hwdec=vaapi while launching it:
Enable VA-API through the configuration file $ ed ~/.config/mpv/mpv.conf a hwdec=vaapi . wq Enable VA-API through the command option $ mpv --hwdec=vaapi <VIDEO>
To check if VA-API is enabled in MPV, play a video and press the key "i" to view its running details. If it shows "hwdec: vaapi" on the top, then VA-API is enabled:

Configuring Firefox
To enable VA-API in Firefox, open the page about:config, and make sure the below two options are set to true:
gfx.webrender.all true media.ffmpeg.vaapi.enabled true
To check if Firefox is working with VA-API, run the following command, and if there is any output showing on the screen, then VA-API is enabled:
$ MOZ_LOG="PlatformDecoderModule:5" firefox 2>&1 | grep "VA-API"

Thanks for reading :)