Problems with frame rate on video conversion using ffmpeg with libx264

Solution 1:

The problem is that ffmpeg chooses the default for -vsync based on the output muxer. Its mp4 muxer defaults to vsync 1, but it chooses a very high framerate so that it can put a frame at the exact right time for every input frame.

(The input frame timing isn't constant. It averages 14.97 fps, according to ffmpeg. Probably from a phone camera? They do variable FPS. I think they slow down to get more light for each frame, but it might be another reason.)

So ffmpeg will duplicate frames up to the 30k fps that it's chosen, or something. h.264 is pretty efficient at storing duplicate frames, but that's ridiculous.

Anyway, the solution is to use -vsync 2 on your ffmpeg command line. Or output to mkv, and then remux to mp4, but the reason that works is that mkv defaults to -vsync 2. It's really that simple. You don't need to make your output CFR. Youtube handles arbitrary frame rates just fine, as long as they're <= 60, and so do most other players. I assume phones are fine, since they make variable FPS videos in the first place. You don't need to use -r something to force frame duplication to hit exactly 30fps or anything.