[FFmpeg-user] Smooth FPS change via ffmpeg
Michael Koch
astroelectronic at t-online.de
Tue Sep 24 00:04:18 EEST 2019
> So, to compute the timestamp of a frame with variable speed:
>
> * Express your frame rate as a complete formula: t → v
>
> * Integrate it: t → f.
>
> * Find the reciprocal: f → t.
Let's give it a try. My input video has framerate=20 and length=10s.
Let's change the framerate linearly from 20 at the beginning to 10 at
the end:
v(t) = 20 - t
After integrating we get f = 20 * t - 0.5 * t^2
The inverse function is t = 20 - sqrt(400 - 2 * f)
ffmpeg -f lavfi -i testsrc2=size=vga:duration=10:rate=20 -lavfi
"setpts='(20-sqrt(400-2*N))/TB' " -y out.mp4
The resulting video gets slower towards the end, but the length is
18.95s and that can't be correct. With a constant framerate of 10 the
length would be 20s. The length should be somewhere wetween 10s and 20s,
but not so close to 20s. Something must be wrong.
This is an interesting question and I would highly appreciate if someone
could post a working example.
Michael
More information about the ffmpeg-user
mailing list