ffmpeg-v4l2-request-fourier / libavcodec61-fourier: H.264 v4l2-request hwaccel not registered #60
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
With the new
libavcodec61-fourier8:7.1.3-0+deb13u1+rpt1+fourier1 installed on higgs (Pi CM5), Firefox-fourier'sInitV4L2RequestDecoderstill fails for H.264 with the same error as before the libavcodec replacement:Root cause
The libavcodec61-fourier build was DONE with
--enable-v4l2-request(verified viaffmpeg -buildconf), but only HEVC ended up with the DRM/v4l2-request hwaccel registered:strings | grep v4l2_requeston the .so confirms:hevc_v4l2requestandv4l2_request_*helper functions; noh264_v4l2requestsymbolsv4l2_request_vp9_*+ff_v4l2_request_reset_picture; also noh264_v4l2requestsymbolsSo both fourier libavcodec variants are missing the H.264 v4l2-request hwaccel module. Kwiboo's fork has it in source (see e.g.
libavcodec/v4l2_request_h264.cupstream); something in the configure / patchset for this build is excluding it.Effect
YouTube serves H.264 by default to Firefox. With the H.264 v4l2-request hwaccel missing, Firefox-fourier falls all the way back to software decode in the RDD process. Symptom: 25-30% CPU on the firefox parent for a single video tab, ~30 fps achieved against a 60 fps source on a Pi CM5 (single Cortex-A76 SW H.264 decode is roughly that fast at 720p) — user-visible as "every other frame dropped".
When YouTube serves HEVC (rare without explicit user override), Firefox-fourier should be able to engage v4l2-request via libavcodec → DRM hwaccel → kernel V4L2 stateless → daedalus or rpi-hevc-dec. HEVC path is testable as a sanity check but doesn't cover the common-case YouTube flow.
Probable fixes (to investigate)
Check the ffmpeg-v4l2-request-fourier configure invocation for whether all per-codec v4l2-request hwaccels are being enabled. Possible the build script narrows
--enable-hwaccel=...to a subset that omits h264_v4l2_request.Check the patch set for Kwiboo's tree — older patches may have been dropped during rebase. Specifically anything touching
libavcodec/v4l2_request_h264.cor that codec's hwaccel registration list.Configure dep check:
v4l2_request_h264_hwaccel_deps="v4l2_request h264 h264_v4l2_request_hwaccel_select"— if one of those deps got disabled by an unrelated--disable-X, it cascades to dropping h264_v4l2request silently. Build log should mention which hwaccels got disabled and why.Related
Test plan
After rebuild with h264 v4l2-request enabled:
ffmpeg -h decoder=h264 | grep 'Supported hardware'showsdrmin the list.strings /usr/lib/aarch64-linux-gnu/libavcodec.so.61.19.101 | grep -i h264.*v4l2requestreturns at least one match.PlatformDecoderModule:5,FFmpegVideo:5shows theInitialising V4L2 stateless (request API) FFmpeg decoderline followed by a successful init, no fall-through to V4L2-DRM or software.Full per-codec audit — only HEVC has DRM hwaccel reachable
Didn't initially enumerate beyond H.264 — fixing that here so the rebuild covers everything in one pass.
Current state (
libavcodec61-fourier 8:7.1.3-0+deb13u1+rpt1+fourier1)Symbol-level confirmation
strings /usr/lib/aarch64-linux-gnu/libavcodec.so.61.19.101 | grep v4l2_request:v4l2_request_hevc_*,v4l2_request_vp9_*,v4l2_request_vp8_*,v4l2_request_mpeg2_*v4l2_request_h264_*, anyv4l2_request_av1_*So for vp9/vp8/mpeg2 the
v4l2_request_*source files DID compile (functions are in the .so), but the per-codec AVHWAccel struct isn't being added to the codec'shw_configslist at link time. That's theCONFIG_VP9_V4L2REQUEST_HWACCELetc. gating inlibavcodec/h264dec.c/vp9dec.cetc.Probable cause: the configure script's per-codec hwaccel dep checks are failing silently (
v4l2_request_h264_hwaccel_depsextrah264_v4l2_request_hwaccel_select). Build log should show e.g.Disabled hwaccels: ... h264_v4l2request vp9_v4l2request ....Complete set to enable in the rebuild
To cover every codec we care about across all consumer paths (Firefox + mpv + ffmpeg CLI on Pi 5 / CM5 / Rockchip):
The vaapi side is fine because libva-v4l2-request-fourier translates VAAPI → V4L2 stateless and the kernel-side stack works for all of these (verified: vp9 via daedalus, hevc via rpi-hevc-dec, h264 via daedalus from ffmpeg CLI). The gap is purely the v4l2-request hwaccel registration in libavcodec which the firefox-fourier patches use directly.
Configure verification step (post-rebuild)
The rebuild's configure output should include all five hwaccels we currently miss:
And post-install verification on a target host:
Should print 'drm' (as part of the Supported hardware devices line) for every codec.
Suspect Kwiboo configure dep
Kwiboo's tree historically requires
h264_v4l2_request_hwaccel_select="h264_decoder"in the configure for the h264 v4l2-request hwaccel to be picked up. Check whether that_selectis set in this build's configure invocation (or in the patch applied on top of upstream). Same dep pattern likely applies to vp9 / vp8 / av1 / mpeg2.If the configure script is failing the dep silently (no error, just disabled output),
--enable-hwaccel=h264_v4l2request,hevc_v4l2request,vp9_v4l2request,vp8_v4l2request,av1_v4l2request,mpeg2_v4l2requestexplicit-list might force-enable them and surface the actual failure if there is one.fourier2 build: hwaccels are now registered for all codecs — but as
AV_HWDEVICE_TYPE_V4L2REQUEST, notAV_HWDEVICE_TYPE_DRM— Firefox patch still missesThe
+rpt1+fourier2rebuild addedv4l2requestto every codec's hwaccel list ✓ — that part of the issue is fixed. But the hwaccel registers with the newerAV_HWDEVICE_TYPE_V4L2REQUESTenum (introduced in FFmpeg ~7.1 as a dedicated type), where the fourier1 build usedAV_HWDEVICE_TYPE_DRM.The firefox-fourier patch
0003-ffmpegvideo-v4l2-request-route.patchwalkshw_configslooking fordevice_type == AV_HWDEVICE_TYPE_DRM. With fourier2's hwaccels declaringdevice_type = AV_HWDEVICE_TYPE_V4L2REQUESTinstead, the patch's walk finds no match and falls through to software — sameno v4l2_request path for codec ID 27log line as before, different underlying cause.Verified on higgs with fourier2 installed: daedalus daemon journal still shows 0 REQ_DECODE for YouTube playback. Firefox stderr/MOZ_LOG repeats the same fall-through chain through
Initialising VA-API FFmpeg decoder→Initialising V4L2 stateless (request API) FFmpeg decoder→no v4l2_request path→Initialising V4L2-DRM FFmpeg decoder→Using preferred software codec h264.Two fix paths
A. Firefox patch update (preferred)
0003-ffmpegvideo-v4l2-request-route.patchand0002-libwrapper-hwdevice-ctx-create.patchneed to accept BOTHAV_HWDEVICE_TYPE_DRMANDAV_HWDEVICE_TYPE_V4L2REQUESTwhen walkinghw_configs, and create the hwdevice ctx with the matching type. Concrete change in patch 3 (thehw_configswalk):Then patch 2's
av_hwdevice_ctx_createcall usestarget_type(DRM or V4L2REQUEST) instead of hardcodedAV_HWDEVICE_TYPE_DRM.Accepting both types future-proofs against the FFmpeg-side transition AND keeps the patches working against older libavcodec builds that still use DRM (Pi 5 / RK hosts on previous fourier versions).
B. Re-pin ffmpeg-fourier to a version that uses DRM
Rollback to whatever fourier1 was based on for the hwaccel
device_typedeclaration. Smaller patch on the ffmpeg side, but locks the campaign to an older base.Recommendation
Ship A. V4L2REQUEST is the canonical new type in upstream FFmpeg and this transition will happen again as future FFmpeg versions reach Debian / rpt. Single Firefox-side patch update covers both.
Happy to draft the Firefox patch update if helpful.