Search code examples
ffmpegmp4h.264video-encodinglibx264

Inconsistent libx264 I-frame interval. Why?


Why is the I-frame interval in some cases inconsistent despite of defyning it as a fixed value?

I'm using ffmpeg and the below command, while the I-frame coded_picture_number goes as follows: 0 10 20 30 38 47 57 ... 196 206 215 225 235 245 255

ffmpeg -i football.y4m -c:v libx264 -bf 0 -g 10 football.mp4

The video data in question is footbal (b) at xiph.org


Solution

  • The encoder can still place an keyframe earlier if it computes that it will be less costly in terms of bitrate. If so, the next KF is due to be placed 10 frames from the premature keyframe.

    To suppress that behaviour, use

    ffmpeg -i football.y4m -c:v libx264 -bf 0 -g 10 -x264opts scenecut=0 football.mp4