[FFmpeg-user] ffmpeg on Raspberry Pi using h264_v4l2m2m hardware acceleration

hydra3333 at gmail.com hydra3333 at gmail.com
Tue Mar 1 13:27:52 EET 2022

Hello. I am attempting to use 64bit ffmpeg (built from latest git) on a Raspberry Pi 4 (aarch64) and am seeing unexpected results.

The input is avc interlaced 1080i25 (PAL country) constant frame rate.

The ffmpeg command below should deinterlace and transcode into progressive avc using the Pi's h264_v4l2m2m hardware acceleration.
/usr/local/bin/ffmpeg -hide_banner -v verbose \
		-i "./some_test_input_file.mp4" \
		-vsync cfr \
		-sws_flags lanczos+accurate_rnd+full_chroma_int+full_chroma_inp \
		-strict experimental \
		-filter_complex "[0:v]yadif=0:0:0,format=pix_fmts=yuv420p" \
		-c:v h264_v4l2m2m \
		-preset slow \
		-pix_fmt yuv420p \
		-qp -1 \
		-g:v 25 \
		-b:v 4000000 -minrate:v 500000 -maxrate:v 5000000 -bufsize:v 5000000 \
		-level 5.2 \
		-movflags +faststart+write_colr \
		-an \
		-y "./some_test_input_file_transcoded_h264_v4l2m2m.mp4" 2>&1 | tee ff.log

The resulting .mp4 is flagged as VFR which is not what I expected nor wanted.

The gop setting is ignored:
[h264_v4l2m2m @ 0x55942ed400] Failed to set gop size: Invalid argument

The Level 5.2 setting is ignored (I suspect the maximum may be L4).

I was hoping to use VBR rather than CBR but can't find a way to set it.

mediainfo on the resulting .mp4 says:
Format profile : High at L4
Format settings, GOP : M=1, N=60
Bit rate mode : CBR
Bit rate mode : Constant
Frame rate mode : VFR
Frame rate mode : Variable

Could someone please point out what I am doing wrong, and how to fix it ?

/usr/local/bin/ffmpeg -version
ffmpeg version git-2022-02-26-df27292-ffmpeg_for_RPi4B_having_h264_v4l2m2m Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --extra-version=ffmpeg_for_RPi4B_having_h264_v4l2m2m --disable-shared --enable-static --enable-pic --enable-neon --disable-w32threads --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --prefix=/usr/local --libdir=/usr/local/lib --bindir=/usr/local/bin --extra-cflags=' -I/usr/local/include -I/usr/include/aarch64-linux-gnu -I/usr/include -L/usr/local/lib -L/usr/lib/aarch64-linux-gnu -L/usr/lib ' --extra-ldflags=' -I/usr/local/include -I/usr/include/aarch64-linux-gnu -I/usr/include -L/usr/local/lib -L/usr/lib/aarch64-linux-gnu -L/usr/lib ' --extra-libs='-lpthread -lm -latomic' --pkg-config=pkg-config --pkg-config-flags=--static --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-avisynth --disable-vapoursynth --disable-libkvazaar --disable-schannel --enable-v4l2-m2m --enable-hardcoded-tables --enable-gray --enable-gmp --enable-gnutls --enable-iconv --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libmp3lame --enable-libtwolame --enable-libfreetype --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libssh --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-librubberband --enable-libwebp --enable-zlib --enable-lzma --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DLIBXML_STATIC

More information about the ffmpeg-user mailing list