[FFmpeg-user] How to set scanline stride value? Corrupted video with RasPi HW encoder

Adam Nielsen a.nielsen at shikadi.net
Sat Oct 23 07:25:40 EEST 2021


Hi all,

I'm having a small issue encoding video with the Raspberry Pi's
hardware encoder, available as a V4L2M2M device that ffmpeg can use in
current firmware/kernel versions.

If I try to encode a video where the width is not a multiple of 64
pixels, I get video corruption.

I opened an issue about it on the Raspberry Pi GitHub repo[1] including
screenshots of the corruption, and they got back to me saying they
suspect ffmpeg is not setting the stride value correctly as reported by
the V4L2M2M interface.

Is there any way to find out what stride value ffmpeg is using and/or
override it, to try to work out whether ffmpeg is setting the wrong
value, or whether the RasPi firmware is supplying the wrong value to
begin with?

If anyone has ffmpeg running on a Pi, then the command listed in the
GitHub issue to reproduce the problem is:

  ffmpeg -f lavfi -i testsrc=size=1296x972:rate=30 -pix_fmt yuv420p -c:v h264_v4l2m2m -f avi - | ffplay -

By adjusting the width of the test video, only values that are
multiples of 64 produce clean video.  Other values produce diagonal
lines across the video as shown in the GitHub issue.

Many thanks,
Adam.

1: https://github.com/raspberrypi/firmware/issues/1608


More information about the ffmpeg-user mailing list