Firefox now supports hardware video acceleration (YouTube etc)

Soldato
Joined
18 Aug 2007
Posts
9,785
Location
Liverpool
In case anyone didn't know, Firefox now finally supports (>v80) hardware video acceleration/decoding on the web, including YouTube etc. This is VAAPI only for now, and works on both Wayland and X11 - though I've found the latter far more useful. As it's X11 support, this works on basically all Linux distros as well as *BSD and it's been flawless for me. I have finally been able to ditch janky ungoogled-chromium installs (patched for VAAPI) and just use the built in Firefox packages with no messing. Win! Tested on Debian Buster and Bullseye, Arch, Fedora 32 and 33, and FreeBSD.

Steps to activate:

1) Firefox needs launching with MOZ_X11_EGL=1 and you can do this either with the launcher, or set it as an environmental variable in /etc/environment or .bashrc/.zshrc/whatever (export MOZ_X11_EGL=1).

2) Change the following preferences in about:config
Code:
gfx.webrender.all:true
media.ffmpeg.dmabuf-textures.enabled:true
media.ffmpeg.vaapi.enabled:true
media.ffvpx.enabled:false

3) Install h264ify or enhanced-h264ify as the acceleration is x264-only at the moment. The former addon works on all sites including embedded videos. The latter only works on YouTube but does allow disabling of volume normalisation and allows you to choose which codecs to allow/disable. Swings and roundabouts.

You will need to have the appropriate hardware drivers for your platform (eg i965 for Intel iGPU, amdgpu+mesa for AMD) as well as the libva and vaapi packages for your platform (libva, libva-intel-driver or similar depending on your hardware). You can test that you're set with vainfo - the package is either called vainfo or libva-utils depending on distro/platform. If vainfo gives a non-error output (i.e. a list of codecs it can decode and encode) you're set.

You can test that it's working by launching Firefox with MOZ_LOG="PlatformDecoderModule:5" - for example by running MOZ_LOG="PlatformDecoderModule:5" firefox in a terminal. While this does restrict you to x264 (and thus 1080p) on YouTube, it's great for low powered laptops etc running on battery (not so much on my Threadripper desktop system, but meh). YMMV but it's pretty easy to get working and the Arch Wiki has some distro-agnostic info if you get stuck.
 
Last edited:
Firefox used to work fine for me until I got a 3080 and now it is laggy and choppy. Turning off video acceleration made no difference. However driver 455.28 seems to have made the problem less severe.

nvidia-smi reports my gpu is using something like 33W then when you scroll nothing happens for about half a second or a second and then it suddenly starts scrolling. Power usage jumps up to 99W momentarily then settles down to sat 66W while scrolling.

On Chrome power usage is 33W and when you start to scroll it might jump up to 36W or 37W, scrolling is super smooth and there is no lag.

Yeah, Nvidia and Linux... When you say you disabled 'video acceleration', did you disable webrender? Was it running in the first place? Are you running OGL? On X11 or Wayland? Lots to play with but the answer is still probably 'Nvidia on Linux'. Have you tried with nouveau?
 
@Cithan I'm glad you got it sorted. WebRender is Mozilla's new rendering engine with more modern supports, hardware aware and much smoother and faster graphics. Now follow the OP and get hardware accelerated video working.

Edit: Actually I'm not sure video hardware acceleration will work with Nvidia due to VAAPI (vs VDPAU).
 
Back
Top Bottom