FireFox Hardware Video Decoding

Has anyone been able to get hardware video decoding working in FireFox on any Linux Distros?

I just hopped to Fedora 35 from Pop!_OS and wasn’t able to get it working on either of those following the instructions on the Arch Wiki.

Anybody else have luck with this?

2 Likes

On Intel, in some cases VA-API might not work with the Intel iHD driver intel-media-driver. This might be workaroundable by using the Intel i965 driver libva-intel-driver. This workaround does not work anymore with Intel Iris Xe graphics, which are only supported by intel-media-driver, only solution there is to wait until Firefox implements a GPU process for X11/Wayland (planned FF94) [14][15] [16].

From the wiki page you linked, it seems hardware acceleration for Firefox with Iris Xe graphics is dependent on waiting for Mozilla to fully implement it.

One way to get around this issue for the time being is to use an external video player, which is helpful for things like YouTube. I can confirm that hardware video acceleration is working with VLC, and also with MPV after some configuration (it’s not enabled by default on mpv), using the open source graphics drivers.

In VLC (and maybe mpv, haven’t tested) you can drag a YouTube URL into a VLC window and it will start streaming it. There’s also a menu option to open a video stream URL and have it play that way instead of click and drag.

There is also software you can use to download full YouTube videos first and then play them off your storage, such as youtube-dl - ArchWiki which is a command line interface. There are graphical layers that are separate that you can use if you don’t want to use the CLI (the wiki page has the links).

I know it’s not exactly what you’re asking for, but it’s what we have for now until Mozilla gets to fully enabling hardware acceleration on Firefox.

3 Likes

This is what I do. I’m working on automating the downloading from specified channels or playlists, as well as automatically naming and file-structur-ing them for PLEX. When I finally get around to finishing that, I’ll post it here if you want.

4 Likes

That would be awesome!

2 Likes

Relevant for FireFox hardware acceleration on linux. I’m seeing a reduction in CPU usage on the framework laptop when playing YouTube videos, but I don’t think it’s fully enabled yet as intel_gpu_top does not report any usage of the video decoder.

3 Likes

Any news on this?

Followed this archwiki to let firefox use vaapi (hardware decoding), but I don’t seem to get it working.

MPV and VLC work with vaapi no problem, check with sudo intel_gpu_top command.

1 Like

There is a bug that prevents current Firefox versions from working with the VA-API. Setting the environment variable MOZ_DISABLE_RDD_SANDBOX=1 is a workaround, but be advised that this essentially disables an important security feature.

There is also an article in the Fedora wiki about this. I’m on Fedora 36 and HW acceleration works as described.

edit:
You can edit the app launcher to make this persistent.

  1. Make a copy of the launcher
    cp /usr/share/applications/firefox.desktop ~/.local/share/applications/
  2. Edit the copy
    vim ~/.local/share/applications/firefox.desktop
    Change Exec=firefox %u to Exec=env MOZ_DISABLE_RDD_SANDBOX=1 firefox %u
  3. Make the same change for every action.
1 Like

@43c Thanks for the info, that workaround is also mentioned in the arch wiki.

But I am not willing to sacrifice security for VAAPI, specially since I don’t know the exact changes with disabling sandbox in firefox.

I got vivaldi working with VAAPI.

EDIT:

If anyone is wondering, this worked for me on vivaldi, it should work on all chromium based browsers with some adjustments.

Launch vivaldi with

vivaldi-stable --use-gl=desktop --disable-features=UseChromeOSDirectVideoDecoder --enable-features=VaapiVideoDecoder --ignore-gpu-blocklist --enable-gpu-rasterization --enable-accelerated-2d-canvas --enable-accelerated-video-decode --enable-zero-copy

or create vivaldi-stable.conf in ~/.config with

–use-gl=desktop
–disable-features=UseChromeOSDirectVideoDecoder
–enable-features=VaapiVideoDecoder
–ignore-gpu-blocklist
–enable-gpu-rasterization
–enable-accelerated-2d-canvas
–enable-accelerated-video-decode

Working on Arch, i3WM, X11, Vivaldi 5.2.2623.39 (Stable channel) stable (64-bit)

1 Like

From the changelog of Firefox 100:

  • Hardware accelerated AV1 video decoding is enabled on Windows with supported GPUs (Intel Gen 11+, AMD RDNA 2 Excluding Navi 24, GeForce 30). Installing the AV1 Video Extension from the Microsoft Store may also be required.

From some reddit posts it looks like they fixed vaapi, I will update en report back.

Added:
It works! In about:config change this two configs to true:

media.ffmpeg.vaapi.enabled
media.rdd-ffmpeg.enabled

While watching a 1080p fullscreen youtube in Firefox:

Same youtube in Vivaldi:

So it uses the GPU but not as much/efficient as vivaldi. Lets see if we can tune it.

1 Like

Hmm, I got this while not even having full screen (1080p though):

@Chiraag_Nataraj I tweaked some settings and now have ±15% video usage. From your intel_gpu_top I can see that you are not using hardware video decoding.

The ‘video’ % indicates if you are using hw decoding. Also, what Firefox version do you have?

Quote:

sudo intel_gpu_top

Start playing video in Firefox and you’ll see the video bar is busy (above 0%) if VA-API starts working.

Ah, okay. I have version 100. I’m wondering if it’s because of firejail… (I’ll have to test).

Also, my ffmpeg (Debian sid) doesn’t enable VAAPI hardware decoding (ffmpeg -buildconf doesn’t show --enable-vaapi), which might also make a difference?

I know that VAAPI is configured correctly because mpv --hwdec=auto does use hardware decoding. So it’s a configuration issue with firefox.

@Chiraag_Nataraj To check if vaapi is supported on your system you can install libva-utils, then check the output of vainfo. There you can see if your system is setup to support vaapi and with codecs it supports.

My output for reference:

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

Yes, VAAPI is supported (I already checked with both vainfo and mpv --hwdec=auto), and the latter works. I’ll debug it at some point lol xD

Hej working on the same issue right now on Ubuntu 22.04 and firefox 100 (via snap), framework (batch 10, i7)

  • Also found and followed this instructions: Firefox - ArchWiki
  • Verified with vainfo that driver is installed and codecs are supported.
  • intel_gpu_top only shows video activity when firefox is started with MOZ_DISABLE_RDD_SANDBOX=1

Will try VLC now.
Any help very appreciated - with my YouTube consume this would be a deal breaker.

(It also caused the whole ubuntu to freeze once with no recovery :confused: but couldn’t reproduce yet.)

Hej @Proximus ,
Could you provide more details on what made your vivaldi work with va-api (FireFox Hardware Video Decoding - #8 by Proximus)?
Launching chromium or vavaldi 5.2.2623.41 with all extra setting didn’t do anything. (Although in contrast to chromium, vivaldi at least supported playing 4k on YouTube)

@JTM

  1. Install intel-media-driver
  2. Enable the advised flags in vivaldi://flags, #enable-vp9-kSVC-decode-acceleration and #canvas-oop-rasterization
  3. Make sure vaapi is working with command vainfo from package libva-utils
  4. Run vivaldi stable with the flags/conf mentioned before

Are you using X11 or Wayland? For Wayland I read that you have to add this flag --ozone-platform-hint=x11

I have intel-media-driver 22.4.1-1

Youtube uses different codecs. This (codec av01) LTT youtube never uses vaapi but this (codec vp09) own always uses vaapi. Youtube switches what codecs they use, haven’t got codec av01 to work yet if it is even supported by our intel gpu. Right-Click on video, click on stats for nerds, there you can see which codec is being used for that video.

Hej @Proximus , thx for the details.
I didn’t set the vivaldi flags before - but they also didn’t help in my case. :confused:
I’m using Ubuntu 22.04 vanilla so I guess Wayland it is, but also adding --ozone-platform-hint=x11 didn’t work for me. I tried activating Wayland native support with --ozone-platform-hint=auto which causes chromium to fail starting with Failed to connect to Wayland display. Vivaldi starts, though also no impact on VA.

I then tried to verify that VLC uses the video and it also doesn’t use VA (test video with VP9).

How do I verify that VA is used:

  • check with intel_gpu_top if it shows 0.00% on Video then its not (it always shows a big bunch on Render/3D)
  • check CPU usage/temperatur with psensor if it shows CPU ~10% and 50+C temp it probably not. (idle is 0% CPU with 30-40C temp)
    for reference: When I use MOZ_DISABLE_RDD_SANDBOX=1 I see 10% on Video, 10% CPU usage with temps ~30-40C

What else could I try? Use X11 instead?

Now I tried starting an Ubuntu on Xorg session - and it worked - at least with vivaldi!
With all these settings vivaldi can now play 4k VP9 videos with substantial usage of the Video acceleration. VLC still does not. firefox v100 still needs disabled sandbox to make use of it.

PS: another side benefit is that the majority of apps are now rendered sharp with fractional scaling in x11 but bad screen tearing happens.

@JTM HW should also be working on Wayland, next time I have to setup my laptop I will set it up with Wayland. Only reason I have not done it yet is because then I will have to change all my config files from i3wm to probably sway.

Google might be your friend to find the flags for Wayland, one I found suggested to edit this ones: --use-gl=egl --ozone-platform-hint=auto.

So try it with this: vivaldi-stable --use-gl=egl --disable-features=UseChromeOSDirectVideoDecoder --enable-features=VaapiVideoDecoder --ignore-gpu-blocklist --enable-gpu-rasterization --enable-accelerated-2d-canvas --enable-accelerated-video-decode --enable-zero-copy --ozone-platform-hint=auto

About VLC, try MPV, worked immediately for me on Xorg. CTRL+H to enable HW. In wayland archwiki suggest to launch it with --gpu-context=wayland. Or to add it to the MPV conf file in ~/.config/mpv/mpv.conf.