[RESPONDED] Video decoding acceleration in Linux

So I noticed deplorable battery life watching youtube et al in browser. Went down the rabbit hole to figure out why.

It occurred to me that hardware video decoding (intel quick sync) should be working, which should save precious battery. With standard intel device drivers I proved that hardware video acceleration works with vlc and intel-gpu-tools (using intel_gpu_top, quick sync isnt working if there is nothing under video% ). Curiously, neither Firefox or Chrome have working hardware video acceleration.

which lead me here…

and here…

and here…
https://wiki.archlinux.org/title/Hardware_video_acceleration

I am currently using Fedora 35. I have proven that OpenGL works with glxgears. I have set flags as needed in chrome and firefox to no avail (I now understand, firefox lacks the correct implementation to use the Intel Xe graphics). I am not opposed to using another supported distro, was going to test with Ubuntu 21.10 later.

I ask, has anyone else gotten any browser video acceleration working? If so what distro and what setup?

will crosspost to r/framework on reddit…

3 Likes

I managed on Chrome (96.0.4664.45, Arch Linux 5.15.5, libva 2.13.0).

After also digging for a while, I mostly followed this post. Note that YouTube usually serves videos encoded with AV1. As pointed out here, you may want to install an extension to force the use of a codec known to be supported for hardware decoding.

Even though the Framework’s GPU should support AV1 decoding, it seems the software support will be coming in mesa 21.3. At least my Arch setup is still at mesa 2.2.5, which I hope explains why AV1 is still not decoded in hardware.

I start Chrome with google-chrome-stable --use-gl=egl --enable-features=VaapiVideoDecoder, and if I look at “about:gpu”, I can see Video Decode: Hardware accelerated, as well as (scrolling down) a number of entries in the table under the section “Video Acceleration Information”:

Decoding (VideoDecoder)	
Decode h264 baseline	16x16 to 4096x4096 pixels
Decode h264 main	16x16 to 4096x4096 pixels
Decode h264 high	16x16 to 4096x4096 pixels
Decode vp8	16x16 to 4096x4096 pixels
Decode vp9 profile0	16x16 to 16384x16384 pixels
Decoding (Legacy VideoDecodeAccelerator)	
Decode h264 baseline	16x16 to 4096x4096 pixels
Decode h264 main	16x16 to 4096x4096 pixels
Decode h264 high	16x16 to 4096x4096 pixels
Decode vp8	16x16 to 4096x4096 pixels
Decode vp9 profile0	16x16 to 16384x16384 pixels
Encoding	

I hope this helps.

1 Like

For reference here are my details…

Fedora 35 kernel 5.15.4-201
Chrome 96.0.4664.45
libva 2.13.0
Graphics driver 21.3.4
mesa 21.2.5 (I think you had a typo)

I was curious about that myself… looking at vainfo, it seems there is an entry for VAProfileAV1Profile0… so according to the vaapi it should support AV1.

It seems that all of the “common” codecs Youtube uses “should” be supported in vaapi, which is what Chrome uses.

Interestingly… based on your recommendation… I just tried a handful of videos.
It seems it is “working” for vp9, vp8 and h264… but not avc1.

Thanks for the reply none the less. I hope between my sources and yours, this helps someone else

I guess we wait for updates to Mesa?

Woops, yeah, I made a type on the mesa version. Mine is the same as yours. Fingers crossed things will work after 21.3. I agree the hardware is capable of hardware decoding.

Even with the various flags I’ve been unable to get VAAPI decoding working in Chrome on Wayland… I can get to where it says video decode is hardware accelerated, but nothing is listed under acceleration information, and as expected there’s no actual acceleration happening in that situation.

I’m not too worried about it but it’s vaguely annoying.

I may sound like a crotchety old man, but… ewh wayland.

I have a few other applications that dont play nice with wayland, so I have to use X11.

for what its worth… you may try these program flags with chrome and see if it helps

google-chrome --use-gl=egl --ozone-platform=wayland

now get off my lawn… sorry old man came out again

I don’t know that it’s possible with the ozone Wayland backend… Looks like there’s a patched version on the AUR to enable it. Maybe you could try some of the other flags listed in the FAQ at the below link? I can give them a try tomorrow. Edit: I can’t get it working with the additional flags, but if you’re on arch you could try using the linked patched version.

https://aur.archlinux.org/packages/chromium-wayland-vaapi/

the flags are different depending on if you are using Wayland or X11.

I got my setup with X11 to work using:
google-chrome --use-gl=desktop --enable-features=VaapiVideoDecoder

I dont use wayland, so I cant verify, but according to my research, this should work:
google-chrome --use-gl=egl --ozone-platform=wayland

you may or may not need --enable-features=VaapiVideoDecoder depending on chrome version and or patch level.

I believe thats what the aur.archlinux.org chromium-wayland-vaapi is all about, enabling the “–enable-features=VaapiVideoDecoder” feature permanently without needing a flag.

Since I use full google-chrome-stable, I need the enable Vaapi flag, since google took away internal program flag.

In the end… google needs to treat linux chrome less crappy and we’ll be happier.

1 Like

I’ll chime in here for the firefox perspective. It currently will work on stable with today’s firefox 96 release! They finally fixed the Xe graphics sandboxing issues (relevant issue: 1698778 - RDD/VAAPI: Sandbox: seccomp sandbox violation by syscall 16 (DRM_IOCTL_VERSION)).

7 Likes

Nice! What settings did you apply to firefox in order to make it work?

See this: Firefox - ArchWiki. Arch wiki is a great resource even if not using arch Linux. I’m using following about:config flags:

media.ffmpeg.vaapi.enabled = true
media.navigator.mediadatadecoder_vpx_enabled = true
media.rdd-ffmpeg.enabled = true
2 Likes

Sigh… it’s not working for me. Need to figure out why vaapi isn’t starting. (manjaro on wayland here)

libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva error: /usr/lib/dri/i965_drv_video.so init failed
libva info: va_openDriver() returns -1

edit: figured it out. Needed to install the intel-media-driver package

2 Likes

I’ve actually already done this and yet on mine it still doesn’t work :confused: I’ll check again later and see the results
Whoops forgot to install intel-media-driver LOL!
It’s now working great on both FFox and Chromium (ungoogled-chromium) :slight_smile:

Yeah it’s the Wayland flags specifically that do not work properly. I believe that version of chromium on the AUR that I linked is patched so that the flags will work, though I haven’t tried since it takes time to compile.

I’m getting really tired… This shitty hardware acceleration in firefox probably will never work.
I spent already 3 hours on getting this work. No chance. It works well with VLC
I did anything.
I’m on

 OS: Fedora Linux 36 (KDE Plasma) x86_64 
Kernel: 5.19.7-200.fc36.x86_64
CPU: 11th Gen Intel i5-1135G7 (8) @ 4.200GHz 
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics]

vainfo

libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.14.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.3.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain               : VAEntrypointEncSliceLP
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointEncSliceLP
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile1            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileVP9Profile3            : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointEncSlice
      VAProfileHEVCMain422_10         : VAEntrypointVLD
      VAProfileHEVCMain422_10         : VAEntrypointEncSlice
      VAProfileHEVCMain422_12         : VAEntrypointVLD
      VAProfileHEVCMain422_12         : VAEntrypointEncSlice
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          : VAEntrypointVLD
      VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         : VAEntrypointVLD
      VAProfileHEVCSccMain444         : VAEntrypointEncSliceLP
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP

installed intel_media_driver, linux_firmware, libva, liva-intel-hybrid-driver, libva-utils

Tried
Run Firefox with the MOZ_LOG="PlatformDecoderModule:5"
Dont find any logs firefox always in shell background even with MOZ_LOG_FILE; doesnt log anything in the related file.

WebRenderering is on and Wayland Mode enabled



Flags used:

media.ffmpeg.vaapi.enabled = true
media.navigator.mediadatadecoder_vpx_enabled = true
media.rdd-ffmpeg.enabled = true

ffmpeg installed from rpmfusion.

It works with VP9 even in vlc… but FF nor h264 (h264fy) either vp9

1 Like

Got it finally working after inspecting the moz log file deeply.

FFMPEG: VA-API works in RDD process only

edited

media.rdd-process.enabled to true
works now !

5 Likes

This answer worked for me on Ubuntu 22.04 running a Firefox fork.

1 Like

I’m on Ubuntu 22.04, and I got no hardware acceleration for YT on Firefox.

The problem was that Firefox was installed with snap, and seemed to have an issue recognizing vaapi installed through apt (sudo apt install intel-media-va-driver).

So, I have uninstalled firefox and reinstalled it with flatpak (apt seems to use the snap version for firefox). And now it’s working (with proper flags turned on)! sudo intel_gpu_top shows video acceleration.

Note that not all YT seem to use hardware. This one does: FLYING OVER SWEDEN (4K UHD) - Relaxing Music Along With Beautiful Nature Videos - 4K Video HD - YouTube

3 Likes

Got it working in Fedora 37 on my 12th gen Framework by following these steps:

Source: Firefox Hardware acceleration - Fedora Project Wiki

  1. Installed ffmpeg
  2. Installed intel-media-driver (I found that the libva-intel-driver package doesn’t support the 12th gen iGPU)
  3. Restart Firefox. (Make sure you’re using the Fedora RPM version of Firefox. I couldn’t find a way to get it working for the Fedora Flatpak version.)

Open a 4k video in YouTube like this one, set the quality to 4k in the YouTube player, and run intel_gpu_top. If the “Video” bar in intel_gpu_top is above 0, then hardware acceleration is working.

Officially we recommend using tlp, unofficially hardware acceleration does help…but it’s a bit of config to get it working. Excellent suggestions provided above, nothing to add.

Power continues to be a focus we’re working on (be it a process), so we do appreciate that there is work to be done here.

2 Likes