12

I've been recently playing around with FFmpeg and I was trying to convert .avi to .gif since other methods I've tried to so far didn't work so well.

What I noticed is that, when I use this command:

ffmpeg -I filename.gif

I can see some of the file information, including the FPS.

And I saw that the highest FPS that is possible so that the video you convert into a gif does not become slower, is 50 FPS.

Now is that correct though? Is the highest FPS amount you can have in a GIF, so that it doesn't become slower 50 FPS?

So do 60 FPS GIF's not exist?

| improve this question | |
21

The GIF98a specification says in the section about the Graphics Control Extension

vii) Delay Time - If not 0, this field specifies the number of hundredths (1/100) of a second to wait before continuing with the processing of the Data Stream. The clock starts ticking immediately after the graphic is rendered. This field may be used in conjunction with the User Input Flag field.

Which means the smallest value is 1 for a image rate of 100 FPS (this will be difficult to render on most monitors...), and the next smallest value is 2 for an image rate of 50 FPS, and the next value is 3 for an image rate of 33.3 FPS. So exactly 60 FPS is not possible.

Note that this extension was meant for a handful of frames with a delay on the order of seconds (maximum delay is about 600 seconds), so 1/100 seconds resolution was ample. It certainly wasn't meant for video, and that's why the field encodes delay, and not frame rate.

Making video GIFs is really an abuse of the specification (even though it's now so common that most people probably don't realize that, just as most people don't realize GIFs and JPEGs use different kinds of compression, and are meant to be used on different kind of images).

| improve this answer | |
  • 5
    One could emulate a 60 fps GIF by setting delay to 2,2,1 for every 3 frames. – Gyan Jun 16 '19 at 15:03
  • So where exactly would you change the Delay Time, and in what unit is the delay time? – karl-police Jun 16 '19 at 15:10
  • The unit is 1/100. As described in the GIF specification, there's a global delay time, and you can also set the delay time for each frame. The location is in the GCE part of the GIF. ffmpeg probably doesn't allow that level of control. – dirkt Jun 16 '19 at 16:45
8

Using ffmpeg, this is the basic format to emulate a rolling average of 60 fps

ffmpeg -i video.mp4 -vf "settb=1/100,setpts='if(eq(N,0),0,if(not(mod(N,3)),PREV_OUTPTS+1,PREV_OUTPTS+2))'" -vsync vfr -r 100  out.gif

To read these files with ffmpeg , while preserving those timings, use

ffmpeg -min_delay 1 -i out.gif ...

which will show

Stream #0:0: Video: gif, bgra, 1280x720 [SAR 64:64 DAR 16:9], 60 fps, 100 tbr, 100 tbn, 100 tbc

It's a different matter whether any given player fulfills these timings.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.