This simple tutorial shows how to enable hardware acceleration, aka GPU rendering, for playing videos in Firefox in Ubuntu and/or Debian.
Firefox supports VA-API hardware video acceleration, but not enabled by default. By enabling it, can offload video rendering from CPU to GPU to get better performance and lower resource usage. And, here’s how to do the job in Linux.
NOTE: This tutorial should work for most Linux with Firefox. But for Fedora 38, user need to install the Flatpak version of Firefox, since the pre-installed one does no longer support the thing!
Step 1: Tell Which Video Codec your Graphics Driver supported
This step is optional. But if you want, it easy to check which codecs are supported by your current graphics driver.
First, open terminal and run command to install the vainfo package:
sudo apt install vainfo
Then run ‘vainfo‘ in terminal to verify.
As the screenshot shows, my GPU driver supports encoding (generate video) via H264 codec, and supports decoding (play video) MPEG2, H264, VP8, HEVC, and VP9 videos.
Step 2: Enable VAAPI hardware video acceleration in Firefox
In Firefox web browser, type about:config in address bar and hit Enter. Then, click ‘Accept the Risk and Continue’ button.
Next, search for following keys and change their values one by one:
media.ffmpeg.vaapi.enabled, and double click on it to set true
media.ffvpx.enabledand set to false.
media.rdd-vpx.enabledand set to false.
media.navigator.mediadatadecoder_vpx_enabledand double-click to set true.
Step 3: Verify
When done step 2, re-launch Firefox and start playing a video, either via local file or website.
For Intel integrated GPU:
- First, open terminal and run command to install the
sudo apt install intel-gpu-tools
- Then, run command, and take a look at the load of “Video” and “VideoEnhance” engines.
For AMD and NVIDIA GPUs:
Open terminal and run command to install the
sudo apt install nvtop
Then, run nvtop command and hit Enter. And, keep an eye on your GPU and MEM load while playing video.
Install Extension for Youtube Video
If hardware video acceleration does not for playing YouTube videos, try installing this browser extension for Firefox: