Log in

View Full Version : x264: Ensuring cfr with lavf/ffms input


Richard1485
27th January 2020, 22:28
I'd like to double-check that I've correctly interpreted how to ensure that x264 uses cfr when using lavf or ffms as the demuxer, because they make x264 vfr aware, resulting in vfr encoding by default (at least with the inputs that I'm feeding it). Specifying the frame-rate results in cfr encoding:


x264 --demuxer lavf/ffms --output /dev/null --fps 24000/1001 ~/input.mkv


According to this wiki (http://www.chaneru.com/Roku/HLS/X264_Settings.htm), --fps implies --force-cfr, so I shouldn't need to set that explicitly. What I want to establish is that the above ensures that vfr never kicks in at all -- in other words, that my video has not gone cfr->vfr->cfr internally, which might conceivably cause problems. So far, my encodings have completed without discernible frame-rate issues, but I'd like to be absolutely sure that I've not overlooked/misinterpreted something.

I'm on Ubuntu 19.10.

sneaker_ger
27th January 2020, 22:55
--fps implies --force-cfr
This is true.

so I shouldn't need to set that explicitly. What I want to establish is that the above ensures that vfr never kicks in at all -- in other words, that my video has not gone cfr->vfr->cfr internally, which might conceivably cause problems. So far, my encodings have completed without discernible frame-rate issues, but I'd like to be absolutely sure that I've not overlooked/misinterpreted something.
I'm not quite sure what you mean. Note that --fps/--force-fps only change the timings and set the cfr flag in the bitstream. They do not actually duplicate/drop frames (or similar mechanism) to convert VFR to CFR. If your source is "true" VFR then you will run into sync problems. If your source is CFR then using --fps is fine.

Richard1485
27th January 2020, 23:09
Note that --fps/--force-fps only change the timings and set the cfr flag in the bitstream. They do not actually duplicate/drop frames (or similar mechanism) to convert VFR to CFR.

That's good to know. I was indeed envisaging such a mechanism, which is what had me concerned.


If your source is "true" VFR then you will run into sync problems. If your source is CFR then using --fps is fine.

My sources are CFR, so thanks for the confirmation.