Video Acceleration on Gentoo
- Posted:
2023-09-27
Over the past few months, I have found myself gradually spending more time on 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 any 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]
Configurations for Gentoo Portage
In order to enable the VA-API feature on my ADM GPU, the driver "radeonsi" should be added to the list of video cards [3]:
# nano /etc/portage/make.conf VIDEO_CARDS="amdgpu radeonsi"
Also, for applications that support VA-VAP, the USE flag "vaapi" can be enabled globally [4]:
# nano /etc/portage/make.conf USE="vaapi"
Then, update the whole system to apply these changes:
# emerge -av --update --deep --newuse @world
From now on, let's set up MPV and Firefox to ensure they can work with VA-API when playing videos.
Settings for MPV
To enable VA-API in MPV, either add hwdec-vaapi to its configuration file, or use the option --hwdec=vaapi while launching it:
configure it with the option $ nano ~/.config/mpv/mpv.conf hwdec=vaapi launch it with the argument $ mpv --hwdec-vaapi
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:

Settings for Firefox
To enable VA-API in Firefox, go to 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, then VA-API is enabled:
$ MOZ_LOG="PlatformDecoderModule:5" firefox 2>&1 | grep "VA-API"

Thanks for reading :)