Hardware support for multimedia codecs in Firefox

This does not work either for the SNAP version or for the Flatpak version of Firefox!

Under Linux Firefox needs some “help” to activate the hardware support for video playback codecs for Nvidia GPUs. Find below what is needed to do so:

First you need to install some packages:


sudo apt install -y meson gstreamer1.0-plugins-bad libffmpeg-nvenc-dev libva-dev libegl-dev libdrm-dev cmake vainfo

Afterwards pull the GIT repo, cd into it and compile and install the vaapi driver:


git clone https://github.com/elFarto/nvidia-vaapi-driver.git
cd nvidia-vaapi-driver
meson setup build
meson install -C build

The following lines need to be added to the file /etc/environment:


sudo touch /etc/environment
sudo tee --append /etc/environment <<EOF
MOZ_DISABLE_RDD_SANDBOX=1
LIBVA_DRIVER_NAME=nvidia
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/10_nvidia.json
EOF

And these to the file /etc/libva.conf:


sudo touch /etc/libva.conf
sudo tee --append /etc/libva.conf <<EOF
LIBVA_MESSAGING_LEVEL=1
EOF

In Firefox you need to open the configuration page about:config and apply the following changes:

  • media.ffmpeg.vaapi.enabled to true
  • media.rdd-ffmpeg.enabled to true
  • media.av1.enabled to false (Optional, disabled AV1 so pages can't use it and fall back to software decoding)
  • gfx.x11-egl.force-enabled to true
  • widget.dmabuf.force-enabled to true

Source: