Ubuntu Testing Chromium Snap With VAAPI (Hardware-Accelerated Video Decoding) Support

Ubuntu is testing a new Chromium snap package that enables VAAPI support, allowing the web browser to take advantage of hardware-accelerated video decoding.

Canonical developer Olivier Tilloy has created a VAAPI-enabled Chromium snap using the Fedora patch (which got Chromium with VAAPI support about 2 weeks ago), and published it in a new candidate/vaapi channel. Thanks to this, Ubuntu and other Linux distributions that can enable Snap support, can easily install Chromium with Video Acceleration API enabled, which should bring smoother video playback, less CPU usage and improved power usage.

Chromium snap vaapi Ubuntu
Chromium VAAPI-enabled snap running in Ubuntu 18.04 - notice the low CPU usage when playing a YouTube video

VAAPI (Video Acceleration API) enables and provides access to hardware-accelerated video processing using the GPU to accelerate video encoding and decoding by offloading processing from the CPU.

Just like on Fedora, the Chromium VAAPI snap comes with the "Hardware-accelerated video decode" flag (available in chrome://flags) enabled by default, so you don't need to do anything to enable GPU accelerated video decoding.

However, some GPUs don't support hardware acceleration for some codecs like VP8 or VP9, so in such cases hardware acceleration won't work out of the box. In YouTube's case, users can force the videos to use h264 instead of VP8/VP9, which is supported by most GPUs, and that way you'll get hardware-accelerated video decoding. This can be done by installing the h264ify Chrome extension.

There's another important aspect to mention. While hardware acceleration is used by default using the Chromium VAAPI snap with Intel GPUs (and I assume AMD GPUs as well, but I can't try this out as I don't have one), that's not the case for Nvidia GPUs.

If the patch used by this Ubuntu snap and by the Fedora package is similar to the one used for Chromium with VAAPI patches PPA, a patched vdpau-va-driver (which implements vaQuerySurfaceAttributes) is needed to enable hardware-accelerated video decoding in Chromium running on Nvidia graphics. Since this is not available directly in Ubuntu, the Chromium VAAPI snap is built without this, so hardware-accelerated video decoding doesn't work with Nvidia GPUs in this case. Either way, this Chromium snap doesn't offer GPU accelerated video decoding with Nvidia graphics.

As an alternative, Ubuntu / Linux Mint users with Nvidia GPUs (or those that don't want to use a Chromium snap package) can install Chromium with VAAPI enabled by using a PPA, which provides a patched vdpau-va-driver.

Chromium snap with VAAPI installation

The Chromium snap with VAAPI enabled is in the candidate/vaapi snap channel, which is not listed in Ubuntu Software, or on the Snap Store. To install it you can use the command line:

sudo snap install --channel=candidate/vaapi chromium

On Linux distributions where snapd is not enabled by default, you can find instructions for installing / enabling it on snapcraft.io.

You can check if Chromium is using hardware-accelerated video decoding by observing its CPU usage when playing videos, which should be a lot lower than using standard Chromium builds. To make sure, you can open a video on YouTube, then open a new tab in Chromium and enter the following in the URL bar: chrome://media-internals .

Chromium snap GPUVideoDecoder video_decoder 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 video_decoder property. If the video_decoder value is GpuVideoDecoder it means that the video that's currently playing on YouTube in the other tab is using hardware-accelerated video decoding.

If it shows FFmpegVideoDecoder or VpxVideoDecoder, accelerated video decoding is not working, or maybe you're using a GPU that doesn't support accelerated video decoding for VP8/VP9, and you forgot to install or disabled the h264ify Chrome extension.

via Phoronix