How To Enable Hardware Acceleration In Chromium On Ubuntu Or Linux Mint (VA-API Patched PPA Builds)

You may have noticed that watching HD videos from Youtube and other similar websites in Google Chrome or Chromium browsers on Linux considerably increases your CPU usage and, if you use a laptop, it gets quite hot and the battery drains very quickly. That's because Chrome / Chromium (Firefox too but there's no way to force this) doesn't support hardware accelerated video decoding on Linux.

This article explains how to install a Chromium beta or development build which includes a patch that enables VA-API on Linux, bringing support for GPU accelerated video decoding, which should significantly decrease the CPU usage when watching HD videos online. The instructions cover only Intel and Nvidia graphics cards, as I don't have an ATI/AMD graphics card to try this, nor do I have experience with such graphics cards, but from what I've read, this should work with ATI/AMD graphics too.

This is Chromium from the Ubuntu (18.04) repositories without GPU accelerated video decoding playing a 1080p YouTube video:

Chromium browser no hardware acceleration

The same 1080p YouTube video playing in Chromium with the VA-API patch and hardware accelerated video decode enabled on Ubuntu 18.04:

Notice the CPU usage in the screenshots. Both screenshots were taken on my old, but still quite powerful desktop. On my laptop, the Chromium CPU usage without hardware acceleration goes way higher.

The patch to add VA-API support to Chromium on Linux, titled "Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only" was was initially submitted to Chromium more than a year ago, but it has yet to be merged.

Chrome has an option to override the software rendering list (#ignore-gpu-blacklist), but this option does not enable hardware accelerated video decoding. After enabling this option, you may find the following when visiting chrome://gpu: "Video Decode: Hardware accelerated", but this does not mean it actually works. Open a HD video on YouTube and check the CPU usage in a tool such as htop (this is what I'm using in the screenshots above to check the CPU usage) - you should see high CPU usage because GPU video decoding is not actually enabled. There's also a section below for how to check if you're actually using hardware accelerated video decoding.

The patches used by the Chromium Ubuntu builds with VA-API enabled used in this article are available here.

As an added benefit, by using Chromium with VA-API installed from PPA you get to have native Chromium builds (actual DEB packages) on Ubuntu, instead of the new default Snap Chromium builds, which Ubuntu has started pushing by default.

Installing and using Chromium browser with VA-API support on Ubuntu or Linux Mint

It should be clear to everyone reading this that Chromium Beta or Dev Branch is not considered stable. So you might find bugs, it may crash, etc. It works fine right now but who knows what may happen after some update. Using the PPAs below will overwrite your current stable Chromium installation (if already installed).

What's more, the Chromium Beta and Dev Branch PPA repositories used in this article requires performing some extra steps if you want to enable Widevine support (so you can play Netflix videos and paid YouTube videos, etc.), or if you need features like Sync (which needs registering an API key and setting it up on your system). Instructions for performing these tweaks are explained in the Chromium Dev Branch PPA description.

For Nvidia graphics, the vdpau video driver needs to be updated in order to implement vaQuerySurfaceAttributes. So a patched vdpau-va-driver is required to use this with Nvidia. Thankfully, the Chromium-dev PPA provides this patched package and I'll link it so you can manually download it in case you want to use the Beta PPA.

Chromium with the VA-API patch is also available for some other Linux distributions, in third-party repositories, like Arch Linux (for Nvidia you'll need this patched libva-vdpau-driver) for example. If you don't use Ubuntu or Linux Mint, you'll have to find these packages yourself.

1. Add the Chromium with VA-API support PPA.

Chromium with VA-API support is available in two PPA repositories - one which has Chromium Beta and another one with Chromium Dev. Choose one from the 2 (and only add one)! The Beta PPA should be more stable.

To add the Chromium Beta branch PPA and install Chromium browser in Ubuntu, Linux Mint, and Ubuntu or Linux Mint flavors like Xubuntu, Kubuntu, Ubuntu MATE, Lubuntu, Linux Mint MATE, et.c, using:

sudo add-apt-repository ppa:saiarcot895/chromium-beta

You can add the Chromium Dev branch PPA and install the latest Chromium browser development build in either Ubuntu or Linux Mint (and other Ubuntu-based Linux distributions, including elementary, as well as Ubuntu or Linux Mint flavors like Xubuntu, Kubuntu, Ubuntu MATE, Linux Mint MATE and so on) using:

sudo add-apt-repository ppa:saiarcot895/chromium-dev

2. Pin the PPA with a priority of 1001.

The Chromium version from the PPA may be overwritten by an Ubuntu update. To avoid this, we can pin the Chromium VAAPI PPA packages to have a priority of 1001 (with 500 being default on Ubuntu, and > 1000 meaning to install the packages even if it's a downgrade), so the packages from the PPA are not overwritten by any Ubuntu updates, and they can be installed even if the version on the system is newer. We'll do this as follows.

  • for the Beta PPA:
Run this in a terminal:

sudo nano /etc/apt/preferences.d/saiarcot895-chromium-beta-pin-1001

And paste the following:

Package: *
Pin: release o=LP-PPA-saiarcot895-chromium-beta
Pin-Priority: 1001

Now save the file and exit (in Nano, save using Ctrl + o, then exit with Ctrl + x).

  • for the Dev PPA:
Run this in a terminal:

sudo nano /etc/apt/preferences.d/saiarcot895-chromium-dev-pin-1001

And paste the following:

Package: *
Pin: release o=LP-PPA-saiarcot895-chromium-dev
Pin-Priority: 1001

Now save the file and exit (in Nano, save using Ctrl + o, then exit with Ctrl + x).

3. Install Chromium Browser from the Saiarcot895 (VA-API) PPA:

sudo apt update

sudo apt install chromium-browser

4. Install the VA-API driver

For Intel graphics cards, you'll need to install the i965-va-driver package (it may already be installed):

sudo apt install i965-va-driver

For Nvidia graphics cards you need the patched vdpau-va-driver from the Chromium Dev PPA. If you've added the Chromium Dev PPA, you can install it using this command:

sudo apt install vdpau-va-driver

For those using Ubuntu 20.10 (for which this package was not yet uploaded to the PPA), you can download the patched vdpau-va-driver DEB package from here, and install it manually. You only need vdpau-video package (you don't need the -dbgsym package) from Ubuntu 20.04 and install that. It works in both Ubuntu 20.10 and 20.04.

5. Enable the Hardware-accelerated video option in Chromium.

Copy and paste the following in the Chrome URL bar: chrome://flags/#enable-accelerated-video-decode (or search for the Hardware-accelerated video decode option in chrome://flags) and enable it, then restart Chromium browser.

On a default Google Chrome / Chromium build, this option shows as unavailable, but you'll be able to enable it now because we've used the VA-API enabled Chromium build.

6. Install h264ify Chrome extension.

YouTube (and probably some other websites as well) uses VP8 or VP9 video codecs by default, and many GPUs don't support hardware decoding for this codec. The h264ify extension will force YouTube to use H.264, which should be supported by most GPUs, instead of VP8/VP9.

This extension can also block 60fps videos, useful on lower end machines.

You can check the codec used by a YouTube video by right-clicking on the video and selecting Stats for nerds. With the h264ify extension enabled, you should see avc / mp4a as the codecs. Without this extension, the codec should be something like vp09 / opus.

7. [Nvidia only] Starting with Chromium 76, Nvidia users must launch Chromium browser with the --use-gl=desktop flag in order to disable ANGLE. Without this, hardware accelerated video decode won't work. 

So you'll need to launch Chromium Browser like this:

chromium-browser --use-gl=desktop

You can copy the Chromium desktop file from /usr/share/applications/ to ~/.local/share/applications/, and modify its Exec line to include this flag. This way when launching Chromium Browser it will automatically use this flag (and it won't be overwritten by updates):

cp /usr/share/applications/chromium-browser.desktop ~/.local/share/applications/

sed -i 's/Exec=chromium-browser %U/Exec=chromium-browser --use-gl=desktop %U/' ~/.local/share/applications/chromium-browser.desktop

How to check if Chromium is using GPU video decoding

Open a video on YouTube. Next, open a new tab in Chromium and enter the following in the URL bar: chrome://media-internals.

On the chrome://media-internals tab, click on the video url (in order to expand it), scroll down and look under Player Properties, and you should find the kVideoDecoderName property. If the kVideoDecoderName value is MojoVideoDecoder (previously it was GpuVideoDecoder, but now the Chromium builds use MojoVideoDecoder on Linux) it means that the video that's currently playing on YouTube in the other tab is using hardware-accelerated video decoding.

Chromium check vaapi mojovideodecoder

If it says FFmpegVideoDecoder or VpxVideoDecoder, accelerated video decoding is not working, or maybe you forgot to install or disabled the h264ify Chrome extension.

If it's not working, you could try to debug it by running chromium-browser from the command line and see if it shows any VA-API related errors. You can also run vainfo (install it in Ubuntu or Linux Mint: sudo apt install vainfo) and vdpauinfo (for Nvidia; install it in Ubuntu or Linux Mint: sudo apt install vdpauinfo) and see if it shows an error.

How to remove Chromium with VA-API patches and use the official stable Ubuntu / Linux Mint Chromium builds

If you want to completely remove the Chromium with VA-API builds from your system, and revert to the official stable Chromium browser builds provided by Ubuntu / Linux Mint, you can purge the PPA.

To purge a PPA you'll need the PPA purge utility, which can be installed using:

sudo apt install ppa-purge

And then purge the Chromium PPA you have added:

  • Chromium Beta PPA:
sudo ppa-purge ppa:saiarcot895/chromium-beta

  • Chromium Dev PPA:
sudo ppa-purge ppa:saiarcot895/chromium-dev

Let's also remove the APT preferences file that we used to pin this PPA, because it's no longer doing anything:

sudo rm /etc/apt/preferences.d/saiarcot895-chromium-*-pin-1001