View Full Version : lossless framerate change with ffmpeg?
BabaG
29th January 2020, 22:02
couldn't quite figure out the right place for this question. please move if wrong.
i haven't found, after a lot of searching, a simple way to change a 23.976fps mov file to a 24fps mov file using ffmpeg. i'm using linux and sometimes windows, btw. the -vf and -r options have been suggested but require a re-encode. i just want to copy the frames from the mov container (it's prores, btw) to a new container that plays at the new rate. i don't want to interpolate or drop frames, just play the same material faster. this used to be fast and easy with apple's cinema tools but those days are long gone.
the closest idea i've been able to come up with is to try to extract the raw or elementary material from the mov and then put it into a new mov container, defining that new container as 24fps in the process. would that work? what would that command look like?
thanks for any tips,
babag
Sharc
30th January 2020, 09:44
Just guessing: Perhaps you find an intermediate container in ffmpeg which accepts copied streams with new time stamps without triggering a re-encode - you would have to experiment though. You may still expect issues with lost audio sync, or dropped/duplicated video frames. Also take note of the difference between putting -r before or after the -i <sourcefile>.
My question is rather why do you want to change the framerate from 23.976 to 24.0 at all? More problems than benefit, I think.....
Perhaps someone with better knowledge of the ffmpeg options can chime in.
BabaG
30th January 2020, 17:56
thanks, sharc.
i'm making dcp file using opendcp which requires 24fps. i used to conform using cinema tools on a mac but that was many years ago and cinema tools is no longer available.
i also am using davinci resolve to export the pre-elements for opendcp. resolve works best with the material conformed to 24fps. the method i've found to work best within resolve is to change the imported file's frame rate to 24fps as soon as it is imported and before it is put on a timeline. i'm unsure, though, about how resolve changes the rate and whether it might be interpolating or dropping frames depending on the change applied. add to that that there are at least five places to address frame rate and i'm unsure about keeping them all aligned so as to get a proper result. since i used to use cinema tools outside of my editor, i thought i might be able to use ffmpeg to replicate this workflow and, thereby, bypass any possible resolve confusion.
problem, for me, is finding out how to get the same number of frames in my converted file without interpolation or dropping frames in the process. same frames, in other words, just a different playback speed. may have to address picture and sound individually in the process. that's why i thought extracting the sound and picture from the mov container might be a way to go, then re-wrapping them into a new container at the new rate. i'm not a sophisticated enough user to know how to do that, though, and need guidance.
interesting thought about the placement of the -r option. there's also a small program i've used called 'avi frame rate changer' that works well but only with avi files. wish i could find something i could use on linux that would do these things.
maybe someone else will chime in with more detail on your thought about containers and simple copying.
thanks again,
babag
Sharc
31st January 2020, 09:20
Try this:
Download and unpack mp4fpsmod.zip from here:
http://www.mediafire.com/file/b6prwftetvbjb7e/mp4fpsmod_32.zip/file
Now run
mp4fpsmod.exe --fps 0:24000/1000 "your_source.mov" -o "newfps.mov"
For more info on mp4fpsmod see
https://github.com/nu774/mp4fpsmod
Edit:
Still you would have to resample the audio to keep audio and video in sync after the video framerate change. May not be necessary for short clips though.
StainlessS
31st January 2020, 10:15
Here is mp4fpsmod on github (with some example commands):- https://github.com/nu774/mp4fpsmod
EDIT: Sharc link is for version 0.25, updated Nov 2018 on github to v0.26. [the _32 at end of Sharc filename is presumably meaning x86 rather than version number].
EDIT: v0.26 is a bugfix version, see bug:- https://github.com/nu774/mp4fpsmod/issues/22
EDIT: OK, I see that Sharc added the github link whilst I was searching for it.
Sharc
31st January 2020, 10:32
Yep. I uploaded the 32 bit version 0.25 which I still had on my HDD.
I didn't find the .exe v0.26 on the GitHub.....
StainlessS
31st January 2020, 10:37
Damn, yes you are correct only source avalable in releases, I downloaded from here:- https://sites.google.com/site/qaacpage/cabinet
which is linked from here on D9:- https://forum.doom9.org/showthread.php?t=161386&highlight=mp4fpsmod
(zip contains a couple of dll's for eg msvcp.dll which is I think maybe VS CPP 2012, not sure, which you of course will not need if system installed).
BabaG
31st January 2020, 19:29
interesting. looks like windows only. that might be ok. is it only for mp4? know if it will take a quicktime mov file? lastly, i guess i'd have to extract the audio, resample, and remux?
thanks,
babag
Sharc
31st January 2020, 20:04
Works for .mov here as well. Just try.
And yes, you will have to demux, resample and remux the audio for keeping it in sync.
If your audio is DTS (ac3) the option -c might help. See the doc. I didn't try all the options.
filler56789
11th February 2020, 13:45
Hmmm, time to upgrade from v0.24 to v0.26...
mp4fpsmod, 64-bit .EXE built with GCC 9.2.0.
http://www.mediafire.com/file/qyrj0d84gfauvdm/mp4fpsmod-0.26-Win64.7z/file
Sharc
11th February 2020, 16:25
:thanks:
richardpl
11th February 2020, 17:46
For typical h264:
$ ffmpeg -i in.mp4 -bsf:v h264_mp4toannexb -c copy -f rawvideo out
$ ffmpeg -r 24 -i out -c copy out.mp4
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.