[FFmpeg-user] Low FPS with H.264 Encoding When Using -pix_fmt yuv420p

German Geraskin german.geraskin at gmail.com
Thu May 23 12:20:41 EEST 2024


>
> Hello,
> when I use the following command in Raspberry Pi 4 model B, I am getting
> only 8 fps for 1080p resolution.
>
> *ffmpeg -use_wallclock_as_timestamps 1 -t 60 -i /dev/video0 -c:v
> h264_v4l2m2m -b:v 8M -maxrate 2M -vsync 2 -bufsize 4M -r 30 -s hd1080
> -pix_fmt yuv420p -g 30 -qmin 20 -qmax 50 output_1080p.mp4*
>
> And when I use the same command, but remove -pix_fmt yuv420p, the output
> video is 27 fps.
>
>
> *ffmpeg -use_wallclock_as_timestamps 1 -t 60 -i /dev/video0 -c:v
> h264_v4l2m2m -b:v 8M -maxrate 2M -vsync 2 -bufsize 4M -r 30 -s hd1080  -g
> 30 -qmin 20 -qmax 50 output1_1080p.mp4*
> Why does the fps reduce when -pix_fmt yuv420p is used in the ffmpeg command?
> Both the output videos have pixel format of YUV420, but when I use
> '-pix_fmt yuv420p' in command, why does it reduce the fps ?
> What are the default settings to tune the Encoding ?

Have you checked what pixel format is default for the input device
(/dev/video0)?

Based on your description, I can suppose that YUV420 is the default
format of the input device.
When you do not use -pix_fmt, the pixels are just transferred from
input device to encoder as is.
When you use -pix_fmt, the pixels are transferred to a pixel
transformation algorithm first,
and then converted pixels are transferred to the encoder.
So your machine spends the processor's time converting pixels from
YUV420 to YUV420.
For Raspberry Pi this could be not an easy task. (I heard that ffmpeg
is too heavy RPi).

I am not an expert neither in ffmpeg implementation nor in RPi
architecture, so above is only my technical intuition.

Have a great day :)


More information about the ffmpeg-user mailing list