whexy1999
Hardware-accelerated Video Decoding in Chrome

Hardware-accelerated Video Decoding in Chrome

Created
Dec 23, 2022 09:24 PM
Last edited time
Dec 25, 2022 01:36 AM
Tags

Current State

In 2022, most video comes with H265 and AV1. For now, only MPEG, H264, VC1, and VP9 are supported in the transformation driver
vdpau-va-driver-vp9
Github
vdpau-va-driver-vp9
Owner
xtknight
Updated
Jul 31, 2023
.
nvidia-vaapi-driver
Github
nvidia-vaapi-driver
Owner
elFarto
Updated
Aug 30, 2023
has a lot of potential. It bases on NVDEC, which is a new API provided by Nvidia. But it will crash Chrome because of limited support
Chrome Support
Github
Chrome Support
Updated
Aug 30, 2023
.
The fundamental reason that we are in this stage is Nvidia and Google are both too stubborn to support each other.
Here it is again. Google doesn't want to add specific code for Nvidia's GPUs because there are so many other GPUs on the market that it would be a lot of work to support all of them. Meanwhile, Nvidia wants to provide specific functionality through its own unique API.
We need an abstraction layer for GPUs! Luckily we have DirectX in Windows, Metal in macOS, and Vulkan in Linux. And Vulkan is expected to support AV1 in 2023. So I believe Chrome will have a good hardware-accelerated video decode solution soon or later.
Developers of Chrome also said in June 2022, “VaapiVideoDecoder is in the process of shipping with Vulkan support now.”
But before that, let’s see how we can add limited support for hardware video decoding to Chrome in 2022.

VA_API transformation driver

⚠️ 2022-12-24 UPDATE: The hardware decoder is extremely unstable. I gave up.
First, install the VDPAU→VA_API transform driver
yay -S libva-vdpau-driver-vp9-git
Use vainfo, you shall see the driver.
❯ vainfo Trying display: wayland Trying display: x11 vainfo: VA-API version: 1.16 (libva 2.16.0) vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA-API - 0.7.4 vainfo: Supported profile and entrypoints VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointVLD VAProfileMPEG4Simple : VAEntrypointVLD VAProfileMPEG4AdvancedSimple : VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264Main : VAEntrypointVLD VAProfileH264High : VAEntrypointVLD VAProfileVC1Simple : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD VAProfileVP9Profile0 : VAEntrypointVLD

Chrome settings

Use the following command to start Chrome (I use the beta version, you can use the stable version as well):
google-chrome-beta --use-gl=desktop \ --use-vulkan \ --enable-features=VaapiVideoDecoder,VaapiVideoEncoder,VaapiIgnoreDriverChecks \ --disable-features=UseChromeOSDirectVideoDecoder
In the Chrome flag settings, enable these:
  • Override software rendering list
  • GPU rasterization
  • Zero-copy rasterizer
  • Hardware decode acceleration for k-SVC VP9

Check

Relaunch Chrome, and open chrome://gpu to check if Video Decode is hardware accelerated.
notion image
That’s not enough. Play a Youtube video and press F12. Click More Options More tools Media to open the Media panel. Check if the hardware decoder is true.
💡
Notice that the hardware decoder won’t always be available due to the limitation of GPU-supported decoding formats. But it should work in most cases.
notion image