HW x264 decoding In Firefox 116

Only way to be sure is to test with the same video with SW and supposedly HW. Make all things equal in your tests. I’m not eat up with h264 HW since youtube defaults to vp9 but I did see that the same guy has V4L HW for VP9 in his future plans for firefox.

1 Like

Further testing Firefox 116 return same/similar conclusion you had summarized, Firefox 116 with ffmpeg 5 or ffmpeg 6 will NOT stream Big Buck Bunny mp4. This round tested on Ubuntu Lunar with ffmpeg-7:5.1.2-3ubuntu1 arm64.

Edit: Correction. Manjaro-Arm-Gnome-linux-aml-6.1.42-1 Firefox 116.0.1 and ffmpeg-6.0-8 is able to stream Big Buck Bunny mp4 and the cpu resources use is similar to Manjaro-Arm-KDE-linux-aml-6.1.42-1 with ffmpeg-m2m.

Now am confused why on Ubuntu Lunar with ffmpeg-5.1 and Fedora 38 Workstation with ffmpeg-6.0 Firefox could NOT stream Big Buck Bunny mp4.

They probably will stream if these boxes are unchecked under Edit ==> Settings then restart firefox.

settings

Manjaro-Arm-Gnome Firefox 116 and ffmpeg-6.0-8 able to stream Big Buck Bunny mp4 with this “Performance” settings:

It will not here on XFCE and pi400.

Interesting.

Manjaro-Arm-Gnome with kernels linux-aml-6.1.42-1 or linux-odroid-6.4.0-1 both on Wayland, Firefox 116 and ffmpeg-6.0-8 stream Big Buck Bunny mp4 with “Performance” settings “Use recommended performance settings” enabled. Currently on linux-odroid-6.4.0-1

Linux jfl-gtkpro 6.4.0-1-MANJARO-ARM-ODROID #1 SMP PREEMPT Mon Jul 10 19:11:53 UTC 2023 aarch64 GNU/Linux

Edit: Further testing of Ubuntu Lunar with Firefox-116.0.3 with ffmpeg-7:5.1.2-3ubuntu1 arm64 with Performace Settings “Enabled” or “Disabled” Big Buck Bunny mp4 will NOT stream,

[Child 4755, MediaDecoderStateMachine #1] WARNING: Decoder=ffff82971b00 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - Error no decoder found for audio/mp4a-latm: file /build/firefox-kucfrI/firefox-116.0.3+build1/dom/media/MediaDecoderStateMachineBase.cpp:166
[Child 4755, MediaDecoderStateMachine #1] WARNING: Decoder=ffff82972a00 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - Error no decoder found for audio/mp4a-latm: file /build/firefox-kucfrI/firefox-116.0.3+build1/dom/media/MediaDecoderStateMachineBase.cpp:166
[Child 4755, MediaDecoderStateMachine #1] WARNING: Decoder=ffff82972100 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - Error no decoder found for audio/mp4a-latm: file /build/firefox-kucfrI/firefox-116.0.3+build1/dom/media/MediaDecoderStateMachineBase.cpp:166
[Child 4755, MediaDecoderStateMachine #1] WARNING: Decoder=ffff82972700 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - Error no decoder found for audio/mp4a-latm: file /build/firefox-kucfrI/firefox-116.0.3+build1/dom/media/MediaDecoderStateMachineBase.cpp:166
Sandbox: attempt to open unexpected file /sys/devices/system/cpu/cpu0/cache/index2/size
Sandbox: attempt to open unexpected file /sys/devices/system/cpu/cpu0/cache/index3/size
Sandbox: attempt to open unexpected file /sys/devices/system/cpu/present
Sandbox: attempt to open unexpected file /sys/devices/system/cpu/possible

Edit 1: Further testing Firefox 116.0.3 with ffmpeg-7:5.1.2-3ubuntu1 on aml-s9xx-box-Lunar-Gnome-6.4.7-meson64 (Armbian Community Build).

Surprise Big Buck Bunny mp4 can stream on Firefox 116.0.3!

found some codes in firefox, so should show v4l2 in about:config, right?

# Hardware-accelerated video decode with VAAPI and V4L2 on Linux
# ==============================================================
@depends(target, toolkit_gtk)
def vaapi(target, toolkit_gtk):
    # VAAPI is mostly used on x86(-64) but is sometimes used on ARM/ARM64 SOCs.
    if target.cpu in ("arm", "aarch64", "x86", "x86_64") and toolkit_gtk:
        return True


@depends(target, toolkit_gtk)
def v4l2(target, toolkit_gtk):
    # V4L2 decode is only used in GTK/Linux and generally only appears on
    # embedded SOCs.
    if target.cpu in ("arm", "aarch64", "riscv64") and toolkit_gtk:
        return True


set_config("MOZ_ENABLE_VAAPI", True, when=vaapi)
set_config("MOZ_ENABLE_V4L2", True, when=v4l2)
set_define("MOZ_ENABLE_VAAPI", True, when=vaapi)
set_define("MOZ_ENABLE_V4L2", True, when=v4l2)

Looks like an environment variable to me.
( ex: Firefox - ArchWiki )

MOZ_ENABLE_V4L2=1 firefox

RPi does dot use VAAPI.

vaapi is default, so we need build firefox add ‘ac_add_options --enable-v4l2’ in mozconfig?

RPi vpu does not use VAAPI. VDPAU and some others do which will be picked up when mozconfig gets run. Firefox uses ffmpeg though which uses v4l.

When you start up firefox in the terminal you will see that it tries VAAPI to see if it works then it moves on like mpv and firefox does.

Maybe this may clear things up some. From the guy that pushed the PR’s for firefox 116.

Summary

Add separate options to control whether we build VA-API and/or V4L2
hardware video decode. These options default to enabled on the
platforms where these decoders are used.

The downstream MOZ_WAYLAND_USE_HWDECODE build option is used within the
FFmpeg platform and is only set when building against a supported
version of the FFmpeg libraries (i.e. not for ffmpeg57).

VA-API and/or V4L2 are enable by default if they are on your system when compiling. They are since the depend ffmpeg pulls both of them in.

The only thing I’m not sure about is The downstream MOZ_WAYLAND_USE_HWDECODE build option part. I do not use wayland and the statement is not clear to me to see whether it is supposedly enabled in firefox build or ffmpeg build.

maybe ubuntu guy 117b build add --enable-v4l2, so flags showed.
btw, had read ffmpeg-rpi 3 patches, useless for v4l2.
thinking back to ffmpeg6, firefox YT 480p CPU over 60% none overclocked.
in my side every ffmpeg version are all same.

I can’t find the PKGBUILD but originally it was built off a guy’s ffmpeg repo that a guy has he made especially for HW decoding on the rpi. kodi-rpi uses it and it works very well. ARCH has ffmpeg-rpi for their vlc-rpi. I have tested vlc-rpi and it worked but not under a DE like kodi-rpi using HW decode. The ffmpeg-m2m package in our repo uses that same guy’s repo also. I may be wrong but I am thinking LibreELEC uses it also.

https://gitlab.manjaro.org/manjaro-arm/packages/community/ffmpeg-m2m/-/blob/master/PKGBUILD#L107

I have read that guy was going to have the same thing for the newer versions of ffmpeg but he has supposedly disappeared.

here you go,

MOZ_WAYLAND_USE_HWDECODE is environment, set to 1 or v4l2? no idea.
MOZ_USE_HWDECODE for X11.

No clue here either.

in Arch’s PKGBUILD even very simple modules need enable, because its not default.
‘ac_add_options --enable-alsa’
‘ac_add_options --enable-jack’

back to Rpi4, firefox-117b8 add ‘ac_add_options --enable-v4l2’ rebuild, if i have a power PC.

Update on Firefox-116. It looks like whether Firefox 116 will stream the Big Buck Bunny mp4 depends on which kernel is being used (at least on my device).

Fedora_38_Workstation with Fedora kernel 6.4.10-200.fc38, Big Buck Bunny mp4 will not stream with Firefox 116.0.2

Fedora_38_Workstation with kernel-6.1.38-zrle-koop-3pole (transplated onto the same Fedora 38), Big Buck Bunny mp4 stream on Firefox 116.0.2.

lsmod|grep v4l2?