FireFox YouTube high CPU usage, even when using hw decoding?

My laptop’s CPU has an Intel iGPU that supports VP9 hardware decoding. When I was using Windows on this laptop, playing 1080p 60fps YouTube videos used almost no CPU at all.

Now that if I play the COSTA RICA video at 1080p 60fps, the CPU usage is about 50%. I checked it with intel_gpu_top and “Video” was being used, which means hardware decoding.

I used yt-dlp and downloaded the 1080p 60fps version with the following command and played it with MPV. The CPU usage was only about 12%~18%.

yt-dlp https://www.youtube.com/watch?v=LXb3EKWsInQ -f 303

Why is it using so much CPU when playing the same video within FireFox? Is it reproducible on your computer, too?

I used a new profile of FireFox that had no extensions and barely any settings changed. Wayland Gnome.

The most likely answer is, Firefox isn’t using hardware video acceleration.

You need to install some things and enable hardware video acceleration. Check out the arch wiki.

No, it’s using hw. Intel gpu top’s video is not zero.

Be sure to verify it is working via the Firefox hardware acceleration section on the arch wiki. Run Firefox like this

MOZ_LOG=“PlatformDecoderModule:5” firefox

and while playing the video look for a “VA-API” string" inside the terminal. That is the only way to be sure hardware acceleration in firefox is working properly. If that works, we can look elsewhere. But for now make sure Firefox is actually using it. Intel top doesn’t matter for now.

I needed -- before MOZ_, otherwise it tried to open that as a URL. Anyway, I did that, and it seems hw decoding was working.

[RDD 141183: MediaPDecoder #2]: D/PlatformDecoderModule FFVPX: VA-API Got one frame output with pts=234067000 dts=234067000 duration=17000 opaque=-9223372036854775808
[RDD 141183: MediaPDecoder #1]: V/PlatformDecoderModule ProcessDecode: mDuration=17000µs ; mTime=234084000µs ; mTimecode=234084000µs
[vp9 @ 0x7f3e02869c00] Param buffer (type 0, 92 bytes) is 0x2.
[vp9 @ 0x7f3e02869c00] Slice 0 param buffer (316 bytes) is 0x1.
[vp9 @ 0x7f3e02869c00] Slice 0 data buffer (694 bytes) is 0.
[vp9 @ 0x7f3e02869c00] Decode to surface 0x7.
[RDD 141183: MediaPDecoder #1]: D/PlatformDecoderModule FFVPX: Frame decode finished, time 0.55 ms averange decode time 0.83 ms decoded 165 frames
[RDD 141183: MediaPDecoder #1]: D/PlatformDecoderModule FFVPX: VA-API Got one frame output with pts=234084000 dts=234084000 duration=17000 opaque=-9223372036854775808
[RDD 141183: MediaPDecoder #2]: V/PlatformDecoderModule ProcessDecode: mDuration=16000µs ; mTime=234101000µs ; mTimecode=234101000µs
[vp9 @ 0x7f3e02869c00] Param buffer (type 0, 92 bytes) is 0.
[vp9 @ 0x7f3e02869c00] Slice 0 param buffer (316 bytes) is 0x1.
[vp9 @ 0x7f3e02869c00] Slice 0 data buffer (102 bytes) is 0x2.
[vp9 @ 0x7f3e02869c00] Decode to surface 0x6.
[RDD 141183: MediaPDecoder #2]: D/PlatformDecoderModule FFVPX: Frame decode finished, time 0.63 ms averange decode time 0.83 ms decoded 166 frames

Yeah, sorry, wrong command. Fixed it.

Okay, next you should check if the video codec is supported by your gpu. Generally you could test different videos on YouTube and see if the outcome is always the same.

If that results in no new information, I don’t know what else to do. MPV seems to work, as you mentioned. So hardware acceleration as a whole seems to work. Maybe check the wiki again for some tips regarding intel setups.

If the vaapi support in Firefox is not good for your GPU, you can try the ff2mpv addon + client.