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:
- Search
media.ffmpeg.vaapi.enabled
, and double click on it to set true - Search
media.ffvpx.enabled
and set to false. - Search
media.rdd-vpx.enabled
and set to false. - Search
media.navigator.mediadatadecoder_vpx_enabled
and 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
intel-gpu-tools
package.sudo apt install intel-gpu-tools
- Then, run command, and take a look at the load of “Video” and “VideoEnhance” engines.
sudo intel_gpu_top
For AMD and NVIDIA GPUs:
Open terminal and run command to install the nvtop
package:
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:
Then use the extension to block VP8, VP9, AV1 video codec to force YouTube to use h264 codec for video playback. Finally, refresh the video page and verify!