Enable VA-API Hardware Acceleration in Firefox on Linux
Streaming high-definition video in the Firefox web browser on Linux often results in high CPU usage, loud fan noise, and rapid battery drain because the browser frequently defaults to software decoding. This article provides a direct, step-by-step guide to enabling Video Acceleration API (VA-API) in Firefox. By installing the correct GPU drivers, adjusting specific browser configuration flags, and verifying the setup, you can offload video decoding to your graphics card for smoother playback and significantly reduced power consumption.
Step 1: Install and Verify VA-API Drivers
Before configuring Firefox, your Linux system must have the correct
VA-API drivers installed for your specific graphics card, along with the
vainfo utility to verify them.
For Intel GPUs: Install
intel-media-driver (for Broadwell 5th Gen and newer) or
libva-intel-driver (for older Intel HD Graphics).
For AMD GPUs: Install the Mesa VA-API drivers,
typically named libva-mesa-driver (Arch/Fedora) or
mesa-va-drivers (Ubuntu/Debian).
For Nvidia GPUs: Nvidia does not natively support
VA-API, so you must install a translation layer. Install the
libva-nvidia-driver (sometimes packaged as
nvidia-vaapi-driver) which translates VA-API calls to
Nvidia's NVDEC.
Verify the Installation: Install the
libva-utils package (which contains the vainfo
command) using your distribution's package manager. Open a terminal and
run:
vainfoIf the output lists several VAProfile entries without
returning an error, your system is ready. Take note of the supported
codecs (such as H264, HEVC, VP9, and AV1) listed in the output, as your
GPU can only accelerate the formats shown here.
Step 2: Enable WebRender and VA-API in Firefox
Once your system drivers are working, you need to instruct Firefox to use them.
- Open Firefox, type
about:configin the address bar, and press Enter. - Click Accept the Risk and Continue.
- In the search bar at the top, look for the following preferences and toggle their values to match the list below by double-clicking them:
media.ffmpeg.vaapi.enabled-> Set to truegfx.webrender.all-> Set to truemedia.hardware-video-decoding.force-enabled-> Set to true
Note for Older GPUs: Websites like YouTube default
to the VP9 or AV1 video codecs. If your vainfo output from
Step 1 only lists H.264 (VAProfileH264...) and not VP9 or
AV1, your CPU will still decode YouTube videos. To fix this, either set
media.av1.enabled to false in
about:config, or install the
enhanced-h264ify browser extension to force websites to
send H.264 video streams that your older GPU can handle.
Step 3: Set Environment Variables (Nvidia Only)
If you are using an Intel or AMD GPU, you can skip this step.
Nvidia users utilizing the nvidia-vaapi-driver must add
specific environment variables to ensure Firefox communicates properly
with the driver. Add the following lines to your
/etc/environment file or your local ~/.profile
file:
MOZ_DISABLE_RDD_SANDBOX=1
LIBVA_DRIVER_NAME=nvidiaLog out and log back into your Linux session for these variables to take effect.
Step 4: Restart and Verify Hardware Decoding
Close all open Firefox windows completely, then relaunch the browser and play a high-resolution video (e.g., a 1080p or 4K video on YouTube).
To confirm that the GPU is now handling the video decoding, use a terminal-based GPU monitoring tool while the video is playing:
- All GPUs: Install and run
nvtop. Look at the DEC (Decoder) percentage. If it is above 0%, hardware acceleration is working. - Intel GPUs: Install
igt-gpu-toolsand runsudo intel_gpu_top. Check the Video engine bar; activity here confirms VA-API is active. - AMD GPUs: Install and run
radeontop. Look for activity under the VCE or UVD/VCN metrics.
If the decoder graphs show activity while the video plays, you have successfully enabled VA-API in Firefox, resulting in lower CPU temperatures and extended battery life.