Why does FFmpeg choose 10+20+20 ms instead of an even 16 ms for 60 fps GIF images?
--
Track title: CC O Beethoven - Piano Sonata No 3 in C
--
Chapters
00:00 Question
01:40 Accepted answer (Score 84)
03:32 Thank you
--
Full question
https://superuser.com/questions/1459724/...
Question links:
[related question]: https://superuser.com/questions/1449366
Accepted answer links:
[Do 60 FPS GIF's actually exist? Or is the maximum 50 FPS?]: https://superuser.com/questions/1449366/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#video #ffmpeg #animatedgif
#avk47
ACCEPTED ANSWER
Score 84
As discussed at Do 60 FPS GIF's actually exist? Or is the maximum 50 FPS?, the resolution of frame times in GIF is 10ms, so a nice even 16ms per frame is not possible. So the answers to the questions, in order, are:
Why is ffmpeg doing this?
Because 10+20+20 gets you 60fps on average, and is the most precise approximation with that property that can be represented within the constraints of the GIF format.
How can I ask it to write a gif that requests an even 16ms per frame instead, so that I don't need to use a second tool?
You can't, because the gif format can't represent that. But I've found that asking it to make a 50fps video -- which can be exactly represented in the GIF format -- produces nice smooth results. This can be done with:
ffmpeg -i foo.flv -vf fps=50 foo.gif
This uses nearest-neighbor temporal interpolation to choose which frame to transfer to the output.
If 16ms is not a time that gif can represent, what is the other tool I'm using doing, and why does it work well?
The other tool I was using was GIMP, and its choice is to round each frame to the nearest representable size, so it was silently changing my requested 16ms/frame to 20ms/frame. It probably works well because my poor human eyes can't tell that everything was happening just slightly too slowly to be correct; only that motions were happening smoothly instead of at unusually-spaced intervals.