HW x264 decoding In Firefox 116

It appears that HW decoding for x264 is coming in firefox 116 August 1st. There is no info I can find so far about configuring it. ./configure --help does not show much light. Another question is does there have to be a special ffmpeg rebuild.

I would like to build the dev branch to play with. If anyone comes across any info please let me know.

https://9to5linux.com/looks-like-firefox-116-will-add-hw-accelerated-video-playback-for-raspberry-pi-4

1 Like

It appears MOZ_WAYLAND_USE_VAAPI has become MOZ_WAYLAND_USE_HWDECODE …

I think the bit for compilation time you are interested in may be this:

if CONFIG['MOZ_ENABLE_VAAPI'] or CONFIG['MOZ_ENABLE_V4L2']:
  UNIFIED_SOURCES += ['../FFmpegVideoFramePool.cpp']
  LOCAL_INCLUDES += ['/third_party/drm/drm/include/libdrm/']
  USE_LIBS += ['mozva']
  DEFINES['MOZ_WAYLAND_USE_HWDECODE'] = 1

don’t forget this ^^

1 Like

116 released. :grin:

1 Like

Amlogiic S922X. Tried Firefox-116.0 on Ubuntu Lunar with this command:

QT_QPA_PLATFORM=wayland GDK_BACKEND=wayland MOZ_ENABLE_V4L2=1 MOZ_WAYLAND_USE_HWDECODE=1 MOZ_ACCELERATED=1 MOZ_ENABLE_WAYLAND=1 MOZ_WEBRENDER=1 firefox --private

Unfortunately no vpu hw acceleration when streaming Youtube.

Is there anything else needed to be set?

did you found media.ffmpeg.vaapi(v4l2).enabled?

Will double check. Most likely not as I don’t think S922X support “vaapi”.

vaapi replaced by something v4l2 or v4l2m2m?

I doubt it will work, It might have to be compiled against ffmpeg with vpu support or ffmpeg with v4l2-m2m enabled, which I doubt ffmpeg6 have v4l2-m2m enabled by default.

Kubuntu-Lunar with kernel-6.1.42-koop-3pole. Firefox 116.0 These are the outputs:

No vpu hw acceleration as far as I can tell.

jfl@opbu:~$ QT_QPA_PLATFORM=wayland GDK_BACKEND=wayland MOZ_ENABLE_V4L2=1 MOZ_WAYLAND_USE_HWDECODE=1 MOZ_ACCELERATED=1 MOZ_ENABLE_WAYLAND=1 MOZ_WEBRENDER=1 firefox --private

Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: DRM render node not
clearly detectable. Falling back to using the only one that was found. (t=4.51349) [GFX1-]: glxtest: DRM render node not clearly detectable. Falling back to using the only one that was found.
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: DRM render node not
clearly detectable. Falling back to using the only one that was found. (t=4.51349) |[1][GFX1-]: vaapitest: ERROR (t=4.63051) [GFX1-]: vaapitest: ERROR
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: DRM render node not
clearly detectable. Falling back to using the only one that was found. (t=4.51349) |[1][GFX1-]: vaapitest: ERROR (t=4.63051) |[2][GFX1-]: vaapitest: VA-API test failed: failed to initialise VAAPI connection. (t=4.63058) [GFX1-]: vaapitest: VA-API test failed: failed to initialise VAAPI connection.

You are most likely correct. But mpv-0.36.0-1 with ffmpeg6 vpu hw acceleration was triggered when playing “x262.mkv” video. So far only with “x264.mkv” but not “h264.mp4” videos.

mpv --gpu-context=wayland --hwdec=v4l2m2m-copy ‘/run/media/jfl/Elements/Movies/English Movies/300.Rise.Of.An.Empire.2014.1080p.BluRay.x264-BLOW[rarbg]/blow-300.rise.of.an.empire.2014.1080p.bluray.x264.mkv’
(+) Video --vid=1 () (h264 1920x800 23.976fps)
(+) Audio --aid=1 --alang=eng () (dts 6ch 48000Hz)
Subs --sid=1 --slang=eng ‘English SDH’ (subrip)
Subs --sid=2 --slang=eng ‘English’ (subrip)
[vo/gpu/wayland] GNOME’s wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pulse] 48000Hz 5.1(side) 6ch float
Using hardware decoding (v4l2m2m-copy).
VO: [gpu] 1920x800 nv12
Invalid video timestamp: 0.000000 → 0.000000
AV: 00:01:40 / 01:42:36 (2%) A-V: 0.000 Dropped: 1 Cache: 125s/150MB

Exiting… (Quit)

Additional Info:

David Turner said,
“I propose to add support to Firefox for using V4L2-M2M video decode accelerators using the FFmpeg platform, in a manner similar to the existing VA-API support”

I might be making some progress with ffmpeg and v4l2m2m. It looks like it is using v4l2m2m when playing big buck bunny.

Using ffplay for video

[ray@jellyfin Extraction.2.2023]$ ffplay -vcodec h264_v4l2m2m -i bbb_sunflower_1080p_30fps_normal.mp4
ffplay version 24bdba45d9 Copyright (c) 2003-2023 the FFmpeg developers
built with gcc 12.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan --host-cflags=‘“-fPIC”’ --arch=aarch64 –enable-v4l2_m2m --enable-v4l2-request --enable-libudev --enable-omx --enable-pic --enable-neon --host-cflags=‘“-fPIC”’
libavutil 58. 2.100 / 58. 2.100
libavcodec 60. 3.100 / 60. 3.100
libavformat 60. 3.100 / 60. 3.100
libavdevice 60. 1.100 / 60. 1.100
libavfilter 9. 3.100 / 9. 3.100
libswscale 7. 1.100 / 7. 1.100
libswresample 4. 10.100 / 4. 10.100
libpostproc 57. 1.100 / 57. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘bbb_sunflower_1080p_30fps_normal.mp4’:
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2013-12-16T17:44:39.000000Z
title : Big Buck Bunny, Sunflower version
artist : Blender Foundation 2008, Janus Bager Kristensen 2013
comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
genre : Animation
composer : Sacha Goedegebure
Duration: 00:10:34.60, start: 0.000000, bitrate: 3481 kb/s
Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2998 kb/s, 30 fps, 30 tbr, 30k tbn (default)
Metadata:
creation_time : 2013-12-16T17:44:39.000000Z
handler_name : GPAC ISO Video Handler
vendor_id : [0][0][0][0]
Stream #0:10x2: Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
creation_time : 2013-12-16T17:44:42.000000Z
handler_name : GPAC ISO Audio Handler
vendor_id : [0][0][0][0]
Stream #0:20x3: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)
Metadata:
creation_time : 2013-12-16T17:44:42.000000Z
handler_name : GPAC ISO Audio Handler
vendor_id : [0][0][0][0]
Side data:
audio service type: main
[h264_v4l2m2m @ 0xffff882e7430] Using device /dev/video10
[h264_v4l2m2m @ 0xffff882e7430] driver ‘bcm2835-codec’ on card ‘bcm2835-codec-decode’ in mplane mode
[h264_v4l2m2m @ 0xffff882e7430] requesting formats: output=H264/none capture=YU12/yuv420p
295.82 A-V: -0.010 fd=1829 aq= 20KB vq= 196KB sq= 0B f=0/0

I won’t know until I can get firefox 116 compiled with this ffmpeg since the one in the repo does not have v4l2m2m enabled. Hopefully I can do it here as I have some restraints locally and if no new depends are required in the new ffmpeg/firefox.

Alarm update to 116.
but can not found ‘media.ffmpeg.v4l2(m2m).enabled’ option?
so, you mean firefox rebuild need ffmpeg-v4l2-request depends?

Not sure what all is needed; the stock ffmpeg does not have v4l2m2m enabled and Firefox has ffmpeg as a depend. There is no guide I can find for 116 to say what extra is needed to compile for the pi4.

I am into 2 hours compiling Firefox 116 so far with arch-arm PKGBJILD to see what happens using my ffmpeg build.

ADDED:

Well my newly compiled firefox did not seem to work very well. In fact mp4 vids had trouble playing when it would play.

ffplay -vcodec h264_v4l2m2m, /dev/video10 but no screen?
Alarm’s 116 with ffmpeg-v4l2-request youtube won’t play :rofl:

I have issues with alarm’s 116 with all ffmpeg’s including their ffmpeg. I went back to their 115

ok, 116 & ffmpeg-v4l2-request then remove h264ify addon.
now can play youtube & big-bunny sample mkv/mp4/vp9.
but, how to check does HW work or not?

1 Like

thought, v4l2 codes merge into vaapi module, so can not found ‘media.ffmpeg.v4l2(m2m).enabled’.
so, just flag ‘true’ to ‘media.ffmpeg.vaapi.enabled’.
am i right?

Hi @Rip2, Successful in getting Firefox-116 to have vpu hw acceleration?

don’t think so, play YT cpu loading average 50%.