How to Enable Video Hardware Acceleration on Flatpak Firefox

Note: So far this has been tested with an AMD GPU, but I believe Intel and Nvidia should also work. This guide also assumes you are running Xorg.

  1. Follow the instructions on the Arch Wiki here on how to verify if your GPU supports hardware acceleration and which codecs it supports.

    • For Fedora: sudo dnf install libva-utils
    • For openSUSE: sudo zypper install libva-utils
    • For openSUSE MicroOS: sudo transactional-update pkg in libva-utils
  2. Install the org.freedesktop.Platform.ffmpeg-full flatpak:

    flatpak install org.freedesktop.Platform.ffmpeg-full 
    

Choose branch 21.08 when prompted (v21.08 is the current ffmpeg runtime version that Firefox uses. This version will need to be updated as Firefox updates their runtime version). (Some people report they also had to install org.freedesktop.Platform.VAAPI.Intel. Maybe that’s only for Intel integrated GPUs? Leave a comment with your feedback.

  1. Set the following environment variable to enable logging so that you can verify hardware acceleration is working later:

    flatpak override --env="MOZ_LOG=PlatformDecoderModule:5" org.mozilla.firefox
    
  2. In Firefox, type about:config in the URL bar and set the following settings:

    gfx.webrender.all=true
    media.ffmpeg.vaapi.enabled=true
    media.ffvpx.enabled=false (maybe not required anymore?)
    media.av1.enabled=false (maybe not required anymore?)
    

    Tip: Clicking the double-arrow icon will set the value to true or false

  1. In Firefox, type about:support in the URL bar, go the “Graphics” table, and confirm that “Compositing” is set to “WebRender”

  1. To allow hardware decoding on YouTube, the video codec used must be supported by the hardware. By default, YouTube streams VP8/VP9 encoded video, and since my GPU doesn’t support decoding of that codec, I use the enhanced-h264ify extension to force H.264 videos on YouTube. I recommend installing this extension if you are in the same position.

  2. Verify that hardware acceleration is working by running the Firefox Flatpak from the terminal with verbose logging: flatpak run --verbose org.mozilla.firefox. Then, open a YouTube video. Right as the video starts playing, look for logs indicating that it’s working. As an example, I will show the relevant lines of output from the logs that I see, indicating that it’s working:

[RDD 437: MediaPDecoder #1]: D/PlatformDecoderModule FFMPEG: Initialising VA-API FFmpeg decoder
[RDD 437: MediaPDecoder #1]: D/PlatformDecoderModule FFMPEG:   codec h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
libva info: VA-API version 1.12.0
...
RDD 437: MediaPDecoder #1]: D/PlatformDecoderModule FFMPEG:   VA-API FFmpeg init successful
...
[RDD 437: MediaPDecoder #1]: D/PlatformDecoderModule FFMPEG: VA-API Got one frame output with pts=1933333 dts=1933334 duration=33333 opaque=-9223372036854775808
1 Like