
Yes, it’s finally here. One and half year after Tom Callaway, Engineering Manager @ Red Hat added the patch to Chromium we also get hardware accelerated video playback for Firefox. It’s shame it took too long but I’m still learning.
The VA-API support in Firefox is a bit specific as it works under Wayland only right now. There isn’t any technical reason for that, I just don’t have enough time to implement it for X11 so Bug 1619523 is waiting for brave hackers.
There are a lot of people who greatly contributed to the Firefox Wayland port. Jan Horak (Red Hat) did all the uneasy Wayland patches reviews I threw at him. Jonas Ådahl (Red Hat) helped me with Wayland backend since the first Wayland patch four years ago. Robert Mader faced various Mutter/Gtk compositor bugs, Kenny Levinsen implemented adaptive Wayland vsync handlers, Jan Andre Ikenmeyer has been tirelessly triaged new Wayland bugs and cleaning bugzilla. Sotaro Ikeda (Mozilla) reviewed almost all Wayland patches for graphics subsystem, Jean-Yves Avenard (Mozilla) reviewed VA-API video patches and Jeff Gilbert (Mozilla) faced to my OpenGL Wayland patches.
The contributor list is not exhaustive as I mentioned only the most active ones who comes to mind right now. There are a lot of people who contribute to Firefox/Wayland. You’re the best!
How to enable it in Fedora?
When you run Gnome Wayland session on Fedora you get Firefox with Wayland backend by default. Make sure you have the latest Firefox 77.0 for Fedora 32 / Fedora 31.
You also need working VA-API acceleration and ffmpeg (valib) packages. They are provided by RPM Fusion repository. Enable it and install ffmpeg, libva and libva-utils.
Intel graphics card
There are two drivers for Intel cards, libva-intel-driver (provides i965_drv_video.so) and libva-intel-hybrid-driver (iHD_drv_video.so). Firefox works with libva-intel-driver only, intel-media-driver is broken due to sandboxing issues (Bug 1619585). I strongly recommend to avoid it all cost and don’t disable media sandbox for it.
AMD graphics card
AMD open source drivers decode video with radeonsi_drv_video.so library which is provided by mesa-dri-drivers package and it comes with Fedora by default.
NVIDIA graphics cards
I have no idea how NVIDIA cards are supported because I don’t owny any. Please refer to Fedora VA-API page for details.
Test VA-API state
When you have the driver set it’s time to prove it. Run vainfo on terminal and check which media formats are decoded on the hardware.
There’s vainfo output from my laptop with integrated Intel UHD Graphics 630. Loads i965_drv_video.so driver and decodes H.264/VP8/VP9 video formats. I don’t expect much more from it – seems to be up.
Configure Firefox
It’s time to whip up the lazy fox 🙂 At about:config set gfx.webrender.enabled and widget.wayland-dmabuf-vaapi.enabled. Restart browser, go to about:support and make sure WebRender is enabled…
…and Window Protocol is Wayland/drm.
Right now you should be able to decode and play clips on your graphics cards only without any CPU interaction.
Get more info from Firefox log
VA-API video playback may not work from various reason. Incompatible video codec, large video size, missing system libraries and so on. All those errors can be diagnosed by Firefox media log. Run on terminal
MOZ_LOG="PlatformDecoderModule:5" MOZ_ENABLE_WAYLAND=1 firefox
and you should see something like
“VA-API FFmpeg init successful” claims the VA-API is up and running, VP9 is the video format and “Got one VAAPI frame output…” line confirms that frame decoding works.
VA-API and Youtube
Unfortunately Youtube tends to serve various video formats, from H.264 to AV1. Actual codec info is shown after right click on video under “Stats for nerds” option.

Youtube video codec can be changed by enhanced-h264ify Firefox add-on, so disable all SW decoded formats there. And that’s it. If you’re running Fedora you should be settled for now.

VA-API with stock Mozilla binaries
Stock Mozilla Firefox 77.0 is missing some important stability/performance VA-API fixes which hit Firefox 78.0 and are backported to Fedora Firefox package. You should grab latest nightly binaries or Developer/Beta versions and run them under Wayland as
MOZ_ENABLE_WAYLAND=1 ./firefox
Mozilla binaries perform VP8/VP9 decoding by bundled libvpx library which is missing VA-API decode path. If your hardware supports it and you want to use VA-API for VP8/VP9 decoding, you need to disable bundled libvpx and force external ffmpeg. Go to about:config and set media.ffvpx.enabled to false. Fedora sets that by default when VA-API is enabled.
Amazing news, thanks so much for working on this! I’ve been following the issue tracker on bugzilla, nice job 🙂
I was wondering if it would be possible to enable this in Fedora out of the box? Am I correct that the reason why we need FFmpeg from RPM Fusion is to allow software fallback if VA-API doesn’t work, and Fedora can’t ship avdec_h264?
Please correct me if I’m wrong, but can’t ffmpeg be built to use openh264 instead of avdec_h264, which combined with Firefox’s automatic openh264 downloading of Cisco binaries would mean we could use that as the fallback software implementation? Is that something that’s in the works? Or is there anything else that’s blocking Firefox from using VA-API through Fedora’s ffmpeg?
LikeLike
We did the va-api playback via. ffmpeg (libavcodec.so) and also Intel needs libva-intel-driver, both from rpmfusion. If openh264 supports va-api it will still needs libva-intel-driver from rpmfusion.
LikeLike
Well the chromium side got a setback when bugs started to appear. The vaapi is currently disabled and now broken(dmabuf).
Anyways, Huge thank to you and everyone else involved for this achievement. The only issue remaining on Firefox is related to sandbox violations and hope it will get fixed too.
Also thanks for enabling dmabuf for us poor radeon GPU card users which do not support DRM modifiers.
LikeLike
Hi Martin,
that’s awesome to hear and I hope to test it later. There’s one thing that is not correct in the article though – the iHD driver is provided by the intel-media-driver package, I’m not sure though what the libva-intel-hybrid-driver package is for…
LikeLike
Updated, Thanks!
LikeLike
> libva-intel-hybrid-driver package is for…
This (fedora) package allows VP8/9 hw decode for libva-intel-driver VA-API backend, as shown with vainfo with/out the package installed. The intel-media-driver (iHD) doesn’t rely on it and would provides VP8/9 support by itself.
It’s unfortunate that the intel-media-driver that targets newer intel hw doesn’t work. Is there any bug reported upstream.
Thanks for this work!
LikeLike
Great work!
Just wanted to note that there is a curly quotation mark in MOZ_LOG=”PlatformDecoderModule:5″ MOZ_ENABLE_WAYLAND=1 firefox which appears to make the logger not work properly.
LikeLike
Fixed, Thanks.
LikeLike
Will video acceleration also work without WebRender, i.e. on hardware which is too old to get supported by WebRender?
LikeLike
No, you need working HW acceleration for it. It may be possible to create a custom build where VA-API is used with old GL compositor but that needs some hacking.
LikeLike
Just tested this, works like a charm. Million times thank you.
LikeLike
Thanks a lot, Martin, that’s a big achievement and a lot of good work! I also just figured that `widget.wayland-dmabuf-webgl.enabled` is enabled by default now, so faster WebGL is already shipped – as long as WR is enabled. So lets go and get that one ready* 🙂
* and fix all the lingering bugs of course
LikeLike
Seems that something is not working on my laptop:
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
This is everything what I see here with:
libva-2.7.1-1.fc33.x86_64
libva-intel-driver-2.4.0-3.fc33.x86_64
firefox-77.0-2.fc33.x86_64
ffmpeg-4.3-0.22.20200531git.fc33.x86_64
LikeLiked by 1 person
That looks correct. For more info you need to enable logging, run MOZ_LOG=”PlatformDecoderModule:5″ firefox on terminal.
LikeLike
gfx.webrender.enabled requires layers.acceleration.force-enabled. gfx.webrender.all implies both, so it’s better to recommend it instead.
LikeLike
I did everything and I have only :
$ MOZ_LOG=”PlatformDecoderModule:5″ MOZ_ENABLE_WAYLAND=1 firefox
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
failed to open /usr/lib64/dri/hybrid_drv_video.so
Not using hybrid_drv_video.so
libva info: va_openDriver() returns 0
LikeLike
Sorry, there are wrong quotes in the example, I fixed it already, run:
MOZ_LOG=”PlatformDecoderModule:5″ MOZ_ENABLE_WAYLAND=1 firefox
LikeLike
This is Awesome! I’ve tested it on my intel laptop: youtube, 1080p, vp9 and with va the cpu usage is noticably better: https://imgur.com/a/4HeP2XK. That work is shifted to gpu, but my very not scientific eyeballing in powertop showed that the overall power usage is very slightly lower too.
LikeLike
This is fricking awesome, I’ve been waiting for a an excuse to switch to swaywm anyway!
Just two quick questions, if i may:
1. Will the about:config tweaks be required going into the future or is this just a hack to make it available now and future firefox versions will have these enabled by default?
2. Why is MOZ_ENABLE_WAYLAND=1 necessary? Shouldn’t firefox start with a wayland backend anyway when started within a wayland wm?
Thanks!
LikeLike
1. It can be default when https://bugzilla.mozilla.org/show_bug.cgi?id=1619585 is fixed and it’s well tested
2. Mozilla Firefox does not run on Wayland by default, see https://bugzilla.mozilla.org/show_bug.cgi?id=1543600
LikeLike
Am I correct that you only need ffmpeg-libs, or do you really need ffmpeg?
LikeLike
You’re right, ffmpeg-libs may be enough.
LikeLike
The libva-intel-hybrid-driver driver adds VP9 support on my hardware (Intel HD 520), but I get a lot of dropped frames with it installed. Without it I get a lot less dropped frames. Apparently my CPU is better at decoding VP9 than my GPU. Just putting it out here, maybe it helps some people with older hardware. Based on the results I’ve disabled av1 and VP9 in enhanced-h264ify.
LikeLike
Thank you for all your work on firefox wayland. Using firefox-nightly with a AMD 290x GPU I had to disable VP9 using the enhancen-h264ify addon but now I have va-api working on youtube. CPU usage went down and hardly any extra GPU usage according to radeontop.
LikeLike
This is all crap. You need broken Mutter/GTK3 for something that should work 10 years ago. You cannot use KDE and x11 at all. You have to hack Firefox to work with bunch of environmental crap, bunch of about:configs and Fedora is missing intel-libva drivers, which are in unsupported external repo (why intel drivers are missing from Fedora repo? Why are they not installed by default? Why installer doesn’t see that there’s an Intel CPU/GPU inside the laptop? 90% laptops have Intel CPU and still Fedora doesn’t install intel drivers nor detects them and you cannot install them from Fedora repo, and you have to add external unreliable ppa. WTF.
Then you have to mess up with two confusing libva-intel and itel-media and I thing all the posts above have it the other way round, since the newer is not intel-media, but libva-intel wich in Fedora is missing dependancy gmm library (graphics memory management). Another thing is that gstremer vaapi and intel-libva has a nasty bug and regression for some time now, which I couldn’t disect- much higher CPU usage while playing avc1/x.264 files. From 2 to 5 times higher CPU usage on never drivers and newer CPUs (Brodwel is max 5% CPU on Debian and Skylyke upwars is like 12-20% CPU on the same video file with newer drivers in Fedora and Arch). Plus there’s more because for older Intel GPUs there was –vo=vaapi and its deprecated now in favour of –vo=gpu but regardless the higher CPU is still present. Plus there might be some “surface” bug with newer f’ed intel drivers/ffmpeg/gst-vaapi combo.
This is all one crappy bullshit. The only solution is to drag and drop the url (or extracted mp4) onto smplayer with mpv as backend. And as of youtube and VP9 Intel is bullshit. You have to download acv1 via youtube-dl and ffmpeg will aoutmatically glue h.264 video and m4a into mp4 container so you can play it with vaapi support (albeit broken with more CPU usage on anything past Debian….).
10 years have passed and we are still behind Windows. One gigantic bullshit.
LikeLike
You may try the view-tube-addon and/or the open-in-vlc-addon. Especially opening YT-vids in VLC helps because of its vaapi-support a lot; on my 10 year old compaq I can run 720p30frames with no problems, CPU running at just 30% (X11, Lubuntu).
(I did not yet test how vaapi-support in FF78 (X11) is coming along…)
LikeLike
Similarly to this experience [1], video hardware decoding is working for me with the intel iHD driver [3] for h264/vp8 and vp9 youtube videos. av01 is software decoded, but firefox doesn’t crash on av01 videos. Disabling av01 for youtube via enhanced-h264ify works fine to enforce hardware decoding for most YT videos.
Logging output for a vp9 YT video (via MOZ_LOG=”PlatformDecoderModule:5″ ):
A few ‘Sandbox decoder rejects requested type’ lines,
A few ‘Sandbox decoder supports requested type’
Upon video init:
[AVHWDeviceContext @ 0x7ff1a992fa80] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics – 20.1.1 ().
[AVHWDeviceContext @ 0x7ff1a992fa80] Driver not found in known nonstandard list, using standard behaviour.
[Child 26848: MediaPDecoder #9]: D/PlatformDecoderModule VA-API FFmpeg init successful
[Child 26848: MediaPDecoder #10]: D/PlatformDecoderModule Choosing FFmpeg pixel format for VA-API video decoding.
[Child 26848: MediaPDecoder #10]: D/PlatformDecoderModule Requesting pixel format VAAPI_VLD
[vp9 @ 0x7ff1aa8c3000] Format vaapi_vld chosen by get_format().
[vp9 @ 0x7ff1aa8c3000] Format vaapi_vld requires hwaccel initialisation.
[vp9 @ 0x7ff1aa8c3000] Considering format 0x3231564e -> nv12.
[vp9 @ 0x7ff1aa8c3000] Picked nv12 (0x3231564e) as best match for yuv420p.
Upon video playback:
“[Child 26848: MediaPDecoder #1]: D/PlatformDecoderModule Got one VAAPI frame output with pts=0 dts=0 duration=42000 opaque=-9223372036854775808
[Child 26848: MediaPDecoder #1]: D/PlatformDecoderModule Created dmabuf UID = 1 HW surface 11
[Child 26848: MediaPDecoder #1]: D/PlatformDecoderModule VAAPIFrameHolder is adding dmabuf surface UID = 1
[Child 26848: MediaPDecoder #1]: D/PlatformDecoderModule VAAPIFrameHolder is releasing dmabuf surface UID = 1”.
So – at least for me – intel-media-driver seems to be able to accelerate the decoding of the most common video codecs with the exception of av01. Though I doubt whether the older driver supports that. This archwiki entry [2] section to imply not.
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1619585#c40
[2] https://wiki.archlinux.org/index.php/Hardware_video_acceleration#VA-API_drivers
[3] vainfo ouput:
vainfo: VA-API version: 1.8 (libva 2.7.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics – 20.1.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
VAProfileVP8Version0_3 : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
LikeLike
Hi,
Since firefox 79 vaapi acceleration is not working correctly in wayland or x11. Video starts working, but with vaapi acceleration but in the middle i get a green screen and video fall to 360p. I get this with firefox 79, 80 and 81. In firefox 78 it worked flawless. My graphic card is a intel iHd
my firefox config gfx.webrender.enabled, widget.wayland-dmabuf-vaapi.enabled and media.ffvpx.enabled set to falso so I can play vp9 in youtube
LikeLike
Fedora has patched it locally, it’s https://bugzilla.mozilla.org/show_bug.cgi?id=1645671
Other distros can take a patch there.
LikeLike
Wonder when the patch will land because it’s still broken with latest Fedora updates.
LikeLike
Yes, I’m going to look at it this week.
LikeLike
In what version can we hope that firefox solves the problem without needed to be patch in a particular distribution?
LikeLike
That should be recent nightly – Firefox 81.
LikeLike
Hi Martin, tanks for your great work. The green issue seems to be fixed in nightly but video error and falls to poor quality (360p) in youtube still persists
LikeLike
What about encoding (for WebRTC) and Nvidia (nvdec/nvenc)? Is that gonna come at some point?
LikeLike
I can’t get vp9/vp8 acceleration to work inside flatpak. h264 in flatpak works, and h264 and vp9/vp8 work on the binary downloaded from mozilla.org, it’s just vp9/vp8 inside of flatpak that’s broken. is this a known issue?
i’m using firefox 81 on debian testing on an intel i7-8650U / UHD 620 (kaby lake)
LikeLike
Yes, this is known issue – https://bugzilla.mozilla.org/show_bug.cgi?id=1622425
LikeLike
that looks like a different issue, since i got vaapi partially working (i think i had to install a newer flatpak ffmpeg build?) but that bug can’t find vaapi at all.
LikeLike
I have fedora 33 Firefox 82.0.2. widget.wayland-dmabuf-vaapi.enabled option is not available. I can add it. Is it ok?
LikeLike
Use media.ffmpeg.vaapi.enabled instead of it.
LikeLiked by 1 person
You mentioned that intel-media-driver is broken due to sandboxing issues. I have a Lenovo x1 Carbon gen 8 laptop with an Intel 10th gen processor Ice Lake. Hardware acceleration is supported by the intel-media-driver. Is the driver still broken? I enabled hw acceleration and it seems to work.
LikeLike
See https://bugzilla.mozilla.org/show_bug.cgi?id=1619585 for details.
There are report it works for some HW.
LikeLiked by 1 person
Hi,
currently this configuration (webrender on wayland is a precondition for VA-API) is broken due to bug https://bugzilla.mozilla.org/show_bug.cgi?id=1672139.
It causes pop-ups of extensions to get not rendered.
It seems like there is a patch available but this is planned to land in Firefox 84.
Would you be so kind to add this patch to the build for Firefox 83.0 for fedora?
Thank you very much in advance.
Kind regards,
Michael
LikeLike
Added to firefox-83.0-13, it’s in updates now (https://bodhi.fedoraproject.org/updates/?packages=firefox)
LikeLike
Thank you. Works perfectly fine.
LikeLike
Will Firefox support DRM hardware acceleration for 4k resolution? Netflix only works on 720P.
LikeLike
DRM decoding is handled by the Widevine plugin – so all limitation that apply to that also apply to Firefox.
Currently this means: no VAAPI, no 4K. The former may get implemented by google devs, the later is unlikely to happen on open systems. AFAIK it’s only allowed on closed down systems that make it as hard as possible to extract the streams. Nothing FF can do something about.
LikeLiked by 1 person
Would resolving this bug enable 4k hardware DRM decoding in firefox?
https://bugzilla.mozilla.org/show_bug.cgi?id=1700815
LikeLike
AFAIK it depends on new libva – https://www.phoronix.com/scan.php?page=news_item&px=Intel-VA-API-LibVA-2.11
LikeLike
It looks like fedora 34 will indeed have libva 2.11. However, I don’t think anything will change until some changes are made with firefox (since it doesn’t try to hardware decode widevine video yet).
https://bodhi.fedoraproject.org/updates/FEDORA-2021-e91bbf4dd6
LikeLike
This no longer works. It worked when Fedora 33 was released but an update broke it. I even tried a fresh install to double check. It worked with a fresh install until I installed the latest updates.
I’d be awesome if someone could get a hold of Martin Stransky and ask him nicely to update this guide. I miss hardware accelerated video playback 🙂
LikeLike
Please file a new bug at bugzilla.mozilla.org/ and needinfo me there. If you have issues with VP8/9 playback that may be https://bugzilla.mozilla.org/show_bug.cgi?id=1673184
LikeLike
got it to work on Fedora 34:
– the key widget.wayland-dmabuf-vaapi.enabled in about:config was not there, so I set media.ffmpeg.vaapi.enabled to true and it works.
Thanks
LikeLike