Firefox – Enable Vaapi Hardware Acceleration on Ubuntu 20.10 with Intel HD 500

firefoxvaapi

My hardware:

  • Intel® Celeron(R) CPU J3455 @ 1.50GHz × 4
  • Mesa Intel® HD Graphics 500 (APL 2)
  • 7,4 GiB RAM
  • Ubuntu 20.10 64-bit, X11

According to several articles on the internet, Firefox v81 / 82 enables vaapi hardware video acceleration on Linux by default.

Looking at about:config via Firefox, I can confirm that media.ffmpeg.vaapi-drm-display.enabled is set to true and media.ffmpeg.vaapi.enabled is set to false.

I successfully installed the necessary drivers for my gpu via sudo apt-get install i965-va-driver vainfo, but Firefox still lacks hardware video acceleration when browsing Youtube (VP9). In addition, I also tried running Firefox via the terminal with the command MOZ_X11_EGL=1 firefox, which indeed starts Firefox, but without video acceleration (Youtube is still dropping a lot of frames).

vainfo:

MrSmith@MrSmith-NUC6CAYH:~$ vainfo
libva info: VA-API version 1.8.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_8
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.8 (libva 2.8.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.2.0 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD

I read that it is necessary to switch to the new webrender in order to actually fully activate and use vaapi video acceleration. Is this true? If so, which about:config entry do I modify?

What am I missing here? How do I enable vaapi hardware video acceleration via Firefox for my Ubuntu 20.10 X11 installation?

Best Answer

After a lot of trial and error, I was able to enable and verify that 4k/60fps vaapi video hardware acceleration is working via VP9 and X11 on my system.

Step #1:

  • Ubuntu should already ship with all the necessary Mesa gpu drivers by default (Intel / Radeon)
  • In my case, I performed sudo apt-get install i965-va-driver vainfo just to be sure
  • Usually sudo apt-get install vainfo should suffice

Step #2:

  • Open a terminal and type vainfo in order to see what codecs your gpu supports (see my initial question further above)

Step #3, launch Firefox and set the following to true via about:config:

 - gfx.webrender.all
 - gfx.webrender.compositor.force-enabled
 - media.ffmpeg.vaapi-drm-display.enabled
 - media.ffmpeg.vaapi.enabled

Step #4, set the following to false, if your gpu supports the VP8/VP9 hardware acceleration:

  • media.ffvpx.enabled

Step #5:

  • Close Firefox
  • Open a terminal and launch Firefox via MOZ_X11_EGL=1 firefox

Step #6:

  • Browse Youtube, for example, and right-click a video -> stats for nerds
  • Check viewport / frames for dropped frames (ideally, you should have zero dropped frames)

Step #7 (optional):

  • Create a shortcut with the env set to MOZ_X11_EGL=1 firefox
  • See here for more infos

That's pretty much it. Have fun!

Related Question