Enable Hardware Video Acceleration in Chrome / Chromium / Firefox on Ubuntu 20.04


This post keep tracking my test enabling video hardware acceleration on Ryzen 2200g and Intel i5-6500 using integrated graphic card.

Table of Contents

  1. Table of Contents
  2. Quick Guide
  3. Testing Video Hardware Acceleration on Chrome/Chromium
    1. GPU Supported Video Codec
    2. Use CloudReady to Test
    3. Test Procedure
    4. CloudReady Test Result
      1. i5-6500 with Intel HD Graphics 530
      2. i5-9400f with nVidia gt720
      3. J3455
      4. Ryzen 2200g
  4. Monitor Hardware Video Acceleration
    1. Intel
    2. AMD
    3. NVIDIA
  5. Terminology
    1. Vulkan, VA-API, & VD-PAU
    2. ANGLE
  6. Installation & Configuration
    1. GPU Drivers
    2. Chrome & Chromium
    3. Firefox
      1. VA-API
      2. Extra Codecs
      3. Firefox Configurations
      4. Verify
  7. Final Thoughts
    1. Chrome
    2. Firefox
  8. Reference

Quick Guide

  1. No huge performance advantage when hardware accelerated video decode has been enabled in Chomre/chromium on i5-6500 and J3455. The CPU usage is still high to me.
  2. Fail to enable hardware accelerated video decode with Ryzen 2200g
  3. It’s easier to test using CloudReady to know if the hardware accelerated video decode feature in Chrome/Chromium is supported.
  4. Some video issues if hardware accelerated video decode is enabled on Ubuntu 20.04LTS.

Testing Video Hardware Acceleration on Chrome/Chromium

Most GPUs have special circutes to decode known video formats. If the hardware accelerated video decode in a software player is enabled and the GPU supports the video format, it uses less CPU. A low-power CPU may play video smoothly with the help of GPU.

However, it’s complex to enable in Chrome/Chromium on Ubuntu 20.04LTS. Some terminology, tools, and tips would help:

  1. Linux video driver architecture
  2. Chrome/Chromium Experiments tricks
  3. Chrome/Chromium command line parameter tricks
  4. Monitor tools for CPU/GPU usage

After spending so much time, I realize the easiest way is to use CloudReady. It is enabled while running on supported hardware.

GPU Supported Video Codec

I use following resources to identify which hardware accelerated video decode is supported by a GPU:

  1. Intel Graphics Technology: 5 Capabilities (GPU video acceleration)
  2. Unified Video Decoder is for AMD decode while Video Coding Engine is for encode.
  3. Nvidia PureVideo

Use CloudReady to Test

Google has created Chrome OS to run on low powered hardware. It is based on Linux. Even a Celeron 2995u in Asus ChromeBox CN62 plays YouTube FHD smoothly.

Neverware is a Google company who has created CloudReady. It is based on the open source Chromium OS. I can explore the tweaks and see if hardware accelerated video decode is supported by running CloudReady.

To create a CloudReady boot drive, get a fast 8GB flash drive and the 64-bit image file. Then I follow the steps to use Chromebook Recovery Utility to create a bootable flash drive from the image file. It boots up without any issues. When I use CloudReady USB Maker to prepare, it never boots.

Chromebook Recovery Utility only restores the image to the flash. Neither resizing the partition to utilize the full flash storage nor creating extra storage partition. I need to clear the “Cached images and files” using the “Clear browsing data” dialog in Chromium frequently to prevent the storage shortage warning.

It can also erases a CloudReady flash. Much more quickly then delete 29 partitions by GParted manually.

Test Procedure

Boot with CloudReady Live and login, launch a Chromium window, install h264ify, and open the following tabs:

  1. chrome://gpu
  2. chrome://flags
  3. chrome://sys-internals/#CPU
  4. [Settings] ➞ [Privacy and security] ➞ [Clear browsing data]
  5. Youtube: 【4K】Tokyo Evening Walk – From Shibuya to Omote-sando, 2020

On the video page, use the right mouse on the video to open [Stats of nerds] to identify the “Codecs” being played. It could be avc1, vp09, or av01. The default format is av01 or vp09. Enable h264ify to force to use avc1.

Next, open [︙] ➞ [More tools] ➞ [Developer tools]. In the side panel, [︙] ➞ [More tools] ➞ [Media] to display detail information about the video, especially the “Decode Name” and “Hardware Decoder” in “Video Decoder” section.

An avc1 video played with the [Stats of nerds] and the media information on ThinkPad L460

chrome://gpu ➞ “Graphics Feature Status” ➞ “Video Decode” indicates are software or hardware accelerated decoding.

chrome://gpu ➞ “Version Information” ➞ “Command Line” displays flags. They are parameters to launch Chrome/Chromium in Terminal on Linux. Some have detail description in chrome://flags.

chrome://sys-internals/#CPU is the only way to monitor CPU usage in CloudReady. I haven’t found any tools to monitor GPU video decode.

CloudReady Test Result

i5-6500 with Intel HD Graphics 530

YouTube shows only AVC1 with hardware accelerated video decoder.

i5-9400f with nVidia gt720

YouTube shows all with software video decoder.

J3455

YouTube shows only AVC1 and VP9 with hardware accelerated video decoder.

Ryzen 2200g

YouTube shows all with software video decoder.

Monitor Hardware Video Acceleration

Intel

$sudo intel_gpu_top
Hardware video acceleration is working if Video/0 is more than 0%.
UHD600 provides video decode capability on Firefox.

AMD

$sudo watch cat /sys/kernel/debug/dri/0/amdgpu_pm_info

Check whether VCN or UVD enables when a video is played. It would refresh every 2 seconds.

radeontop shows nothing related to video decode. Both UVD (decode) and VCE (encode) usage are not tracked.

$sudo apt install radeontop
$sudo radeontop

NVIDIA

nvidia-smi ships with NVIDIA’s proprierity drivers. It provides memory usage, GPU utilization, and temperature.

If the GPU is decoding, the GPU usage should increase while the CPU decrease. I also use the build-in System Monitor to check.

More discussion is in askUbuntu. If you know any tools to monitor GPU video decode, please shared in comments.

Terminology

There are many new terminology while reading posts. It’s easy to confuse video hardware accelerated and video decode hard accelerated. The former is for general display while the latter is supported video format decode.

Vulkan, VA-API, & VD-PAU

Vulkan, VA-API, and VD-PAU are all video APIs. Video software needs to access GPU through these APIs. Vulkan is for applications while the others are video codecs.

ANGLE

ANGLE is similiar to Vulkan for redneings rather than providing codecs.

Installation & Configuration

After testing with CloudReady, I might need to install extra driver/kernel module to provide the right VA-API and VD-PAU. Sometimes it works with certain version number only.

Monitor tools help to check GPU usage. When the GPU usage increase after enabling video decode hardware acceleration, the CPU usage should decrease.

GPU Drivers

Both Intel, AMD, and NVIDIA Nouveau supports VA-API.

Linux has build-in support for Intel, AMD, and nVidia. It’s not necessary to install additional driver for Intel and AMD. But nVidia gt720 needs, the defaul driver plays videos like slow motion.

For AMD GPU running on Ubuntu 20.04, follow here or search from the upper [DRIVERS AND SUPPORT] menu to install the AMD proprietary OpenGL, OpenCL, and Vulkan drivers. It’s not necessary for APU (processors with graphics).

Here is the detail steps. To remove, run ./amdgpu-install --uninstall to uninstall. There is no such file “amdgpu-uninstall”.

Chrome & Chromium

In Chrome, open chrome://flags and enable following flags:

  • Override software rendering list
  • GPU rasterization
  • Zero-copy rasterizer

Launch with “$google-chrome --enable-features=VaapiVideoDecoder” in a terminal. Open chrome://gpu and it should indicate “Video Decode: Hardware accelerated”.

The “--enable-features=VaapiVideoDecoder” in chrome-flags.conf will be ignored. It needs to be specified in command line.

For Chromium, replace google-chrome by chromium in command line. Others are the same.

For detail steps, check How To Enable Hardware Accelerated Video Decode In Google Chrome, Brave, Vivaldi And Opera Browsers On Debian, Ubuntu Or Linux Mint and [HowTo] Enable Hardware Video Acceleration / Video Decode In Google Chrome, Brave, Vivaldi And Opera Browsers.

For Arch Linux, following links are very useful hardware video accleration resources for Chrome/Chromium and other applications:

  1. Chromium: 2.5 Hardware video acceleration
  2. Hardware video acceleration
  3. GDM
  4. GStreamer: 3.4 Hardware video acceleration
  5. FFmpeg: 2.13 Hardware video acceleration

Firefox

Enable VA-API in Wayland, install additional codecs, and change some flags to enable.

VA-API

Edit /etc/environment and add the following options.

export LIBVA_DRIVER_NAME= xxx #Replace xxx by iHD for Intel, radeonsi for AMD, nouveau for NVIDIA Nouveau, and nvidia for VUIDIA's propriety driver
export MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_ENABLE_WAYLAND=1

Extra Codecs

$sudo apt install libavcodec-extra
$sudo apt install ubuntu-restricted-addons

Firefox Configurations

Run about:config in Firefox URL and toggle following options:

"media.ffmpeg.vaapi.enabled" ➞ true
"media.ffvpx.enabled" ➞ false
"media.navigator.mediadatadecoder_vpx_enabled" ➞ true
"media.rdd-vpx.enabled" ➞ false
"gfx.webrender.all" ➞ true

Verify

Run about:support in Firefox URL.

If the “Window Protocol” is “wayland” and the “Compositing” is “WebRender”, video decode hardware acceleration is enabled.

Please see detail in Enable FireFox Hardware Video Acceleration on Ubuntu.

Final Thoughts

Chrome

I have successfully enable “Video Decode: Hardware accelerated” on an i5-6500 running Ubuntu 20.04.

While watching supported video formats on YouTube, I didn’t see any indicators change dramagically in intel_gpu_top. System Monitor also doesn’t show any decreasing on CPU usage, either.

On a ThinkPad L460 with i5-6200u and HD520 running Windows 10, I have enable video decode acceleration on Chrome 91.0.4472.101 but the appliend workaround “disable_accelerated_vp9_decode” diables it again. Neither avc1 aka h.264 nor vp9 videos have hardware decode accelerated. Firefox 89.0 has 1 to 4% GPU video decode usages on avc1 videos.

Some said they have lower CPU usage considerably with limited version of Chrome / Chromium. Once upgrade, it’s gone.

I decide to ignore hardware accelerated video decode on Linux. It’s easier to use CloudReady to watch YouTube on a slow computer.

Firefox

Comparing to Chrome/Chromium, I can see intel_gpu_top indicating the hardware accelerated video decoder does work. Strangely, the CPU usages doesn’t change much.

Reference

  1. Wiki: Intel Graphics Technology: 5 Capabilities (GPU video acceleration)
  2. Wiki: Unified Video Decoder
  3. Wiki: Video Coding Engine
  4. Wiki: Nvidia PureVideo
  5. Neverware: CloudReady for Home: Free Download
  6. Neverware: Install Guide
  7. Chrome Web Store: Chromebook Recovery Utility
  8. Chrome Web Store: h264ify
  9. Youtube: 【4K】Tokyo Evening Walk – From Shibuya to Omote-sando, 2020
  10. Wiki: Wilkan (API)
  11. Wiki: Video Acceleration API
  12. Wiki: VD-PAU
  13. Wiki: ANGLE (software)
  14. AMD: Radeon™ Software for Linux® 21.10 Release Notes
  15. AMD: DRIVERS AND SUPPORT
  16. GitHub: clbr / radeontop
  17. GitHub: clbr /radeontop: question: which metric shows H264 decoding? #96
  18. nVidia DEVELOPER: NVIDIA System Management Interface
  19. askUbuntu: How to measure GPU usage?
  20. Read the Docs: Radeon™ Software for Linux® Installation
  21. Linux Uprising: How To Enable Hardware Accelerated Video Decode In Google Chrome, Brave, Vivaldi And Opera Browsers On Debian, Ubuntu Or Linux Mint
  22. Manjaro Team: [HowTo] Enable Hardware Video Acceleration / Video Decode In Google Chrome, Brave, Vivaldi And Opera Browsers
  23. ArchLinux: Chromium: 2.5 Hardware video acceleration
  24. ArchLinux: Hardware video acceleration
  25. ArchLinux: GDM
  26. ArchLinux: GStreamer: 3.4 Hardware video acceleration
  27. ArchLinux: FFmpeg: 2.13 Hardware video acceleration
  28. ArchLinux: Firefox: 4.2.3 Hardware video acceleration

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.