Question

I'm trying to get the duration and frame count from animated gif files so I can calculate the average framerate of the gif and then convert it to a video.

I came across this image recently during my testing and it seems to make everything believe it has a 0ms duration.

enter image description here

Why? How can I find the real duration?

So far I've tried:

  • exiftool

    exiftool -v image.gif

  • ImageMagick

    identify -verbose -format "Frame %s: %Tcs\n" image.gif

  • This Python script which uses the Python Imaging Library

  • And a couple other programs which are used for animating gifs such as Microsoft Gif Animator
Was it helpful?

Solution

The actual duration of this GIF animation really is zero seconds. It has 41 frames, and each of them has a frame duration of zero. (It also has a malformed XMP record, but that's irrelevant here.)

An infinite frame rate is obviously quite stupid, and there's no reason why your browser should even bother trying to display it. What in fact happens is that your browser slows down the frame rate of GIF animations like this so that they can actually be displayed sensibly without tying up your processor or giving you epileptic seizures.

There's no specific standard behaviour, but generally any GIF with a frame delay of less than 0.05 or 0.06 seconds per frame is liable to be be slowed down by web browsers.

References:

http://blogs.msdn.com/b/ieinternals/archive/2010/06/08/animated-gifs-slow-down-to-under-20-frames-per-second.aspx

http://forums.mozillazine.org/viewtopic.php?t=108528

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top