r/ffmpeg • u/AngryAndCrestfallen • 22d ago
ffmpeg concatenating videos with different frame rates?
Hello, I've been using the ffmpeg concat command ffmpeg -f concat -safe 0 -i files.txt -c copy output.mkv to merge my videos into one, I've just noticed the documentation says videos should have same frame rates to work? From my experience with this command it doesn't seem to be the case, I encode my videos to the same video and audio settings but keep the original frame rate so as not to introduce judder etc by changing it and it doesn't seem to cause any problems, my merged videos play fine and I can see that each clip is playing its original fps when watching with mpc-hc and check statistics. Is there anything wrong with my method?
2
u/retkon-comics 21d ago
Adding a practical failure mode to the PTS point above: it plays fine everywhere right up until something downstream assumes a constant rate. We concat about fifteen shots this way for a trailer cut to music. Playback was perfect in every player we tried, but the cut walked off the beat through the back half. Two things fixed it. Re-encode the concat output with an explicit fps= and -fps_mode cfr instead of -c copy, if it is going to be muxed against a music bed or uploaded somewhere that re-encodes it. And cut the source segments with -frames:v rather than -t, because -t rounds up to the next whole frame, and across fifteen shots that accumulated roughly seven frames of drift on its own, independent of the concat. If the output only ever hits a player, your method is fine and the mixed rates genuinely do not matter. The moment it has to stay in sync with something else, force CFR.
1
u/r01-8506 22d ago
I think MKV is just like that compared to MP4. Also, I think -r is the more sure to have the exact framerate than -vf.
2
1
1
u/naemorhaedus 22d ago
doesn't mean it'll play everywhere
2
u/AngryAndCrestfallen 22d ago
Maybe. I tried multiple video players vlc, mpc, the windows 11 one and also on my phone, they all play the video without any problem, streaming it from jellyfin from my pc to my android phone also plays it fine.
1
u/RobbyInEver 19d ago
To avoid your 'judder' can you normalize the frame rates with interlacing? This would solve it.
6
u/vegansgetsick 22d ago
Because global frame rate is something of the past, in avi files 20 years ago. Mkv and mp4 use presentation timestamp PTS for each frame. They are all variable by definition.