[FFmpeg-user] Why does changing Y4M frame rate cause a 4x larger encoded H264 size?

Moses DeJong mo at modejong.com
Fri Feb 22 00:20:10 EET 2019


Hello all

I recently ran into a very strange result while encoding video with ffmpeg+x264 on a MacOSX 10.14.2 machine:

I have a piece of software that converts a series of PNG images to .y4m for use as input to ffmpeg and x264.

I built ffmpeg from source:

ffmpeg -version
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)

When creating Y4M with 30 FPS frame rate:

ffmpeg -y -i CarSpin.y4m -c:v libx264 -pix_fmt yuv420p -preset:v slow -profile:v main -tune:v animation -crf 23 -color_primaries bt709 -color_trc iec61966_2_1 -colorspace bt709 CarSpin.m4v

CarSpin.m4v
977422 bytes
977 KB

When the same video data is written as Y4M with a 1 FPS header.

(ffmpeg command line is the same)

CarSpin.m4v
4000022 bytes
4 MB

The Y4M video file emitted here is exactly the same except for the fps header value.

At first, I thought size diff must have something to do with detection/emitting of keyframes. But, after messing around with a bunch of options it appears that only a single keyframe is being emitted in either case. This is a very short video containing only 155 frames.

So, the encoding size difference must have something to do with delta frames, why would the frame rate effect the output size so much? I also noticed that if I turned the FPS up to 60 FPS that the encoded size went down to about 700 Kb.

What might be going on here and how could I get ffmpeg or x264 to get the higher compression results seen with 30 or 60 FPS in the Y4m header but with the low frame rate settings in the header? The frame rate defined in the M4V output header controls playback rate and I am not able to say encode a 30 FPS video and then play it back at 1 FPS on the client side.

thanks much
Mo


More information about the ffmpeg-user mailing list