In this past year there has been work to make Firefox hardware decode video on Linux. Ubuntu 21.04’s switch to wayland luckily makes this feature more accessible and easier to enable.
Hardware video decoding in Firefox greatly reduces CPU usage when watching video. This saves power, improves thermals and reduces fan noise, all while ensuring computer resources are more free to do other things while watching video.
While the feature is not perfect, I have been reliably using it for several months now on various distros. For me this feature is the difference between 4k web video being playable or not at all.
Here are steps for Ubuntu 21.04, for devices with Intel and AMD graphics (Nvidia is problematic). Older Ubuntu versions and other distros may need additional steps as mentioned below.
Ensure all media codecs and libraries are installed with
sudo apt install ubuntu-restricted-extras. This may not be necessary, but I found it necessary on a fresh 21.04 install (I didn’t check off the box to third party drivers during installation).
Navigate to about:config in Firefox and set the following flags:
true. Enables the feature.
false. Disables the internal software decoders for VP8/VP9, which currently overrule hardware accelerated video.
false. Needed due to Firefox trying to put some video decoding in a remote video process. This currently breaks accelerated VP8/VP9 video decoding.
true. Enables hardware decoding for WebRTC, which is used on web based video conferencing apps.
On Intel hardware, test the feature by running the following :
sudo apt install intel-gpu-tools
If the video bar is above 0% the feature is working.
As a general test you can compare cpu usage when this feature is enabled vs disabled.
If the feature isn’t working navigate to about:support and ensure you see the following values. Note on relatively modern Intel and AMD hardware these are usually enabled by default.
Window Protocol: wayland
WebRender is Firefox’s hardware accelerated rendering, which is needed for video decoding. You may also have luck with Firefox’s legacy OpenGL renderer. This feature is also possible to enable on x11 as mentioned below (I’d recommend wayland since I have found x11 to perform much worse with this feature).
A not linux-specific issue is that YouTube will try to play video codecs that are not hardware accelerated by your device. This extension lets you control what codecs YouTube uses. To confirm this in YouTube right click the video and click ‘stats for nerds’ to ensure the video codec used can be accelerated by your gpu. For Intel gpu video codec support see this matrix.
The feature does not currently seem to work on Nvidia hardware. This is likely since Nvidia does not natively support VA-API and dmabuf which this Firefox feature uses.
YouTube VR videos do not seem to work when this feature is enabled.
Sometimes I notice the video output turns solid green after it has been paused. Since this immediately goes away after playback is resumed I don’t consider it a major issue.
Devices with multiple gpus, such as a device with an integrated Intel gpu and a dedicated Nvidia gpu may not work correctly with this feature.
If you are on Ubuntu 20.04 or non wayland sessions you can still enable this feature, however, you may need to complete a extra steps (in addition to the above instructions).
To enable the feature on xorg append:
export MOZ_X11_EGL=1 to
To enable the feature on wayland append (not needed on 21.04):
export MOZ_ENABLE_WAYLAND=1 to
Even with some issues that come with this feature (like YouTube VR video being broken) there are massive performance upsides with higher resolution video. Hopefully, if there is not too much breakage this feature could be enabled by default in future Ubuntu releases.
This info is mostly sourced from these pages as well as my own testing:
Comprehensive Arch Wiki page with more information
The meta Firefox bug for this issue
Blog post when the feature first landed