[FFmpeg-user] iMovie created variable frame rates cause a/v sync problems
thljcl
jiachielee at live.com
Mon Jul 22 23:06:37 CEST 2013
I come across video of variable frame rate when I tried to encode video with
the constant frame rate of
15 FPS into video with the constant frame rate of 24 FPS. I typically create
batch files to let command
interpreter execute a series of command sequence, instead of entering only a
line of command once at a
time.
ffmpeg -i "input.mkv" -r "24" -vcodec "libx264" -crf "0" "output.mkv"
Unknown to me, however, ffmpeg would encode the video into a video of
variable frame rate when the frame
rate of the source is lower than output video. The unintended consequence
would be that the output video
is out of sync with audio. Without changing the “playback speed”, changing
frame rate itself will
inevitably result in the change of video length, even though such difference
may be negligible. “Out of
sync” is obviously caused by unintended change of playback speed of the
output video.
Of course, a video of variable frame rate can be created by joining videos
of different (constant) frame
rate together. The solution is obviously to avoid unintended change of
playback speed of the output
video. If I can make the output video having constant frame rate, I thought
that the output video might
be able to be in sync with audio.
If the input video is of constant frame rate, it is possible to convert it
to a series of image
sequence.
mkdir "output"
ffmpeg -i "input.mkv" "output\f_%%1d.png"
What if the input video is of variable frame rate?
It turns out the image sequence cannot have variable frame rate. I
specifically joining three videos
together; each of them with the length of one second; first is of 15 FPS;
second is of 24 FPS; third is
of 30 FPS. Media Player Classic reports the joined video is of 15 FPS and
variable frame rate. The
average frame rate of the joined video would be 23 FPS; but Media Player
Classic only reports 15 FPS,
which is the frame rate for the first second. When I use the commands:
mkdir "output"
ffmpeg -i "input.mkv" "output\f_%%1d.png"
ffmpeg actually makes the image sequence of 15 FPS when no frame rate as
output option is being
specified. In this case, it actually needs to drop frames to achieve the
frame rate of 15 FPS.
When it comes to suitable frame rate, it’s worth mentioning that the basic
notion of video is that human
eyes can only discriminate up to 12-15 frames every second, subject to light
condition and other
factors; the film industry commonly adopts 24 FPS as the standard frame
rate.
The short answer would be:
mkdir "output"
ffmpeg -i "input.mkv" -r "24" "output\f_%%1d.png"
ffmpeg -r "24" -i "output\f_%%1d.png" -vcodec "libx264" -crf "0"
"output.mkv"
rmdir /s /q "output"
Here I use Constant Rate Factor of “0”, which is lossless encoding of x264.
--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/iMovie-created-variable-frame-rates-cause-a-v-sync-problems-tp939895p4660121.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
More information about the ffmpeg-user
mailing list