M BUZZ CRAZE NEWS
// news

Change framerate on MKV container

By Sarah Rodriguez

I got a problem with playback of some MKV containers (89 items, totalling 196,3 GB).

The audio+video are encoded in 25 fps, but the subs are totally out of sync - these are encoded on 23.976 fps.

My question: Is there anyway i can batch change/reencode the framerate on these movies to 23.976?

7

3 Answers

You can try recoding the video and audio to a different frame rate while keeping the subtitles as they are:

ffmpeg -i input.mkv -c:v libx264 -crf 21 -c:a aac -strict experimental -b:a 128k -r 23.98 -c:s copy output.mkv

The CRF sets the video quality. Choose something lower for even better quality, like 18. 23 is the default for x264.

1

As people said in the comments, the right way to handle the problem you're actually trying to solve is to tweak the subtitles, or tell your player they're for a different speed video. (e.g. mpv --sub-fps 25 will keep subs for a 25fps show in sync with a 24/1.001 fps copy of it.) ()

But to answer the actual question:

You don't need to re-encode to change the fps. ffmpeg can't remux with new timestamps without re-encoding, unfortunately, but that's a design limitation of ffmpeg. Video encoding is lossy and very slow, so don't do it.

Try mkvmerge --default-duration 0:24000/1001fps --fix-bitstream-timing-information 0 in.mkv -o out.mkv to change the video FPS. That won't touch the audio timing, so you will get a/v desync. 0: selects track 0 in your input file, which I think is usually the video.

You will need to re-encode the audio after processing it with a pitch-preserving speedup filter. I usually only do this at playback time with mpv / mplayer's scaletempo filter (mpv inserts it automatically). ffmpeg has an atempo filter which probably does the trick.

So mux the slowed-down audio with the 24/1.001fps video, and you should have a working file again.

I didn't really test all this, because normally you never need to do this. Just tell your player what speed the subs are for. And you can even use mpv --speed 25025/24000 -subfps 25 myfile.mkv to on-the-fly play back your video at 25fps, if you have a 24/1.001 fps copy of a British show that was originally 25fps, and you want to play it back at the original speed, with constant-pitch audio speedup.

no need to encode and lose quality, for windows at least. Use subtitle edit software, go to synchronization, change frame rate from the one of your original subtitle to whatever you want, save to new synched subtitle afterward.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy