Solved

Frame rate in animated gif

Posted on 1999-01-04
40
2,248 Views
Last Modified: 2013-12-20
I have written an application creating animated gifs.
In my case I want the highest possible frame rate so
I have set "Delay Time" to zero in the "Graphic Control
Extension" block.  
But there seems to exist a minimum delay time.
My framerate is stuck at about 20 fps regardless
of image size.
Is there any way to get around this ??
I would like to be able to display this up
to the cpu capacity.
Maybe I should add that my animations are small
areas with action in a quite large fixed background
image. Typicly a few 20*20 areas in a 400*300 image.

rehn

0
Comment
Question by:rehn
40 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1866102
There is no limit apart from the speed limit of your CPU.
http://www.intel.com/business/intelinsideprogram/optcontent/cookbook%209807.htm
0
 

Author Comment

by:rehn
ID: 1866103
Well... that's what I expected BUT:
I have a test animation containing 1065 frames.
Most of them are very small "updating" frames
in a 376x282 image. (98Kb)
Gif Construction Set needs 59 s to run it in
a 450 MHz PII, 63 s to run it in a 100 MHz P5.
Tests using Netscape 4.5 shows similar results.
Tests using Netscape 3.0 in 100 MHz P5 gives 7 s !!!
If you care to check, the animation can be found
at www.canit.se\~rehn\aqq.gif
What is going on ?
Something wrong in the
"Graphic Control Extension" block ??  

rehn

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1866104
The gif does not work at all in IE4
0
 

Author Comment

by:rehn
ID: 1866105
Strange ! I can display it using
IE 4.0 Version 4.72.3110.8
What happend ? Did you get the
"broken image" symbol ?
Can you see www.canit.se/~rehn/bqc.gif ?

rehn

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1866106
Yes, I can see both. But they do not animate
0
 

Author Comment

by:rehn
ID: 1866107
They animate here, 3 different programs.
Netscape, IE and Gif constructions set.
Do you bother to check into this futher or....?

rehn


0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866108
re:  www.canit.se/~rehn/bqc.gif - I am running Win98, IE version 4.72.3110 SP1a.  It loaded and animated, though it took quite a long time to actualize.  It did work, though.  Thought I'd try right-clicking and saving to see if I can use one of the products to test the frame rate, etc.... but the file presented an option to save only as a BMP file, did you not use a GIF optimizer?  

Have you tried using something like Ulead's Gif Animator version 2, which was available for download or version 3 on trial to see if you can modify?  Another possibility is Adobe's ImageReady.

In my IE, I have View, Internet Options, Advanced, Multimedia Options set to check all elements, including animations, perhaps that wasn't the case on another check done where it failed.
0
 

Author Comment

by:rehn
ID: 1866109
www.canit.se/~rehn/bqc.gif is a big "normal" animated gif file.
It is the file www.canit.se/~rehn/aqq.gif(98Kb) that causes my troubles. It is strange that IE can't save them as gif's.
I have no problem downloading them using NetScape 3.0 and 4.5
and saving as gifs and then redisplay from disk. ( thou NS 3.0
had some problems after one loop ).
In aqq.gif I have used some special data reductions. It works
well exept for the fact that the framerate is too low with most
viewers. But if I use NS 3.0(old) I get the framerate that I am expecting. I have read all docs I've found about animated gifs
( not much ) and I have found nothing about any max framrate.
I have not tried Ulead's Gif Animator nor Adobe's ImageReady (yet).
 
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866110
Both will allow you to modify the DELAY, which modifies timing.
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866111
Does your existing application allow you to enter negative values to further modify frame rate?  The aqq.gif had some strange occurrences when I tried to view properties, it began to over-run my IE window - a first.  Have you tried using a lower resolution background image (the one that is quite large) and/or with less colors to see if this makes a difference?  Does the construction set you have allow you to scrap redundant colors, etc.?  I'm thinking size is impacting the issue.
0
 

Author Comment

by:rehn
ID: 1866112
At first: The animations are 100% created by my application.
Gif constructions set is only used to check the results.

DELAY is set to 0 in aqq.gif, and as it is an unsigned variable
in the specification it can't be set to a negative number.

The background image has the same resolution and palette
as the background image. ( using just one global palette in
the animation, the 216 color "netscape" palette )
They are just small rectangles within the background.

"it began to over-run my IE window - a first"
Well, how do you mean "over-run" ?
How long time did your EI needed to run aqq.

0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866113
The animation download completed after about 1.5 mins, using a 33.6 modem.  When I highlighted it in IE and selected file/properties, the image distorted (background) and started to refresh in blotches and lines, the actual properties windows had the descriptors over-written and illegible.  Really strange.  I'm set to 800X600 with 32bit color depth,plenty of RAM and VideoRam.  Have no idea how or why this occurred, but it happened twice.  Again, right-click only gave the option to save as a BMP file versus a GIF animation.
0
 
LVL 1

Expert Comment

by:ikxsoft
ID: 1866114
try setting the delay time to 1 rather than 0
0
 

Author Comment

by:rehn
ID: 1866115
I have tryed setting the delay time to 1. It seems like IE are confused if it is set to 0.
NetScape 4.5 animate with 0 or 1 put too slow.
NetScape 3.0 animate at expected speed but is confused after one loop
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866116
This is ULEADs link, you'll find some good information here relative to your situation and should prove helpful.  They also address playback, frame rate, AOL limiations and so on.

http://www.webutilities.com/supp_main.htm
0
 

Author Comment

by:rehn
ID: 1866117
I have tried Ulead's Gif Animator, it couldn't handle my gifs, maybe they are to large ( 0.3 - 1.6 Mb ).
A lot of info about animated gifs in general but nothing useful about frame rate.
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866118
Size and environment impact frame rate, no?
0
 

Author Comment

by:rehn
ID: 1866119
Animation speed is not limited by CPU capacity.
As I wrote before:
I have a test animation containing 1065 frames.
Most of them are very small "updating" frames
in a 376x282 image. (98Kb) Gif Construction Set needs 59 s to run it in
a 450 MHz PII, 63 s to run it in a 100 MHz P5.
Tests using Netscape 4.5 shows similar results.

Tests using
 ----->>Netscape 3.0 in 100 MHz P5 gives 7 s !!! <<----- !!!
It seems like NS3.0 runs at full speed, but NS4.5 has some
sort of "speed limit"

If you care to check, the animation can be found
at www.canit.se\~rehn\aqq.gif
It think IE have problems with it too.  
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866120
Checked this aqq.gif before, checked it again just now, same result.  If it were recognized as a true animated GIF ready for the internet, at right-click save picture as should have given me the option to save as a GIF file, but it didn't, only as a bitmap (BMP file).  Thus, I continue to think that there is more to the problem than frame rate.

I use IE 4.72.3110, which is 40-bit, version SP1a.  It does animate somewhat.  

You said that ULEAD GIF Animator couldn't handle it, but if only a BMP file versus animated GIF, property-wise, something is askew.

I'm baffled.
0
 

Author Comment

by:rehn
ID: 1866121
1? I can download aqq.gif using IE, same version as you, save it as gif, and redisplay it using NS. So ??

2! I admit that my animation aqq.gif is unusual. I am using "transparent color" and "dirty rectangles" compression methods to a very large extent. But only within specification as far I can see. "Gif constructions set" can handle it but animate too slow.
The "dirty rectangles" are very many, and most of the are very small, some of them only 1 pixel. But there is nothing in the gif specification saying that it's not allowed. To me it seems like most writers of gif display programs are making some assumptions about the files they are going to display that's not in the spec. Or maybe they are using the basic display software from the same source. As I said before NS 3.0 animate aqq.gif at the speed I expect ( 7 s on a 100 MHz ). I admit that 1 pixel "dirty rectangles" is not very meaningful but this is only a test case for the method.


I'm baffled too. And I appreciate your effort to help me.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:rehn
ID: 1866122
I have now made the testfile "aqq.gif" available as www.canit.se/~rehn/aqq.zip
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866123
In meetings most of today, will check when I can.
0
 
LVL 2

Expert Comment

by:johnny99
ID: 1866124
I don't have an answer but that bqc.gif file is just huge, because it isn't optimised.

I just dwonloaded it and optimised it and it went from 1.5 MB to 900 KB.

Even so, we're talking about misusing a format here: this kind of thing is not supposed to be done using an animated GIF, it's supposed to be done using MPEG, Quicktime, Vivo or whatever.

Just my 2c.


0
 

Author Comment

by:rehn
ID: 1866125
to: johnny99
Well ...
If You read question history, you will see it is not bqc.gif I have problems with. I know it is big and ugly. And it is replaced now btw. It is the file aqq.gif that animates too slowly.
And Yes...I am checking other formats too. What you see on my home page is just test cases.
As is happes, gif animations is just what I need, IF I am able to controll animaton speed. In NS 3.0 I can, with no other viewers I can't. So where is the hidden "speed limit" ??  I have found NO documentation indicating any speed limit in gif animations.
0
 
LVL 2

Expert Comment

by:johnny99
ID: 1866126
OK I had a look at your acq.gif.

MSIE refused to even look at it ("the attempt to load acq.gif has failed") and Netscape loaded it, after a long time, and ran it very slowly and jerkily.

For the record, I've noticed big BIG differences between the speed at which various browsers animate gifs. From Netscape 2 to 3 there was a huge jump in speed, and a noticeable lurch on resuming a loop disappeared.

If I'm permitted another 2c, it's just too big, in pixels, to work well, and, simply because there ARE those differences in how browsers render the animation onscreen, animated gif is NOT the right format for you to do this kind of thing. I really think you've got to take a step back from the problem and try another angle. You're beating your head against a brick wall!

Good luck,

j
0
 

Author Comment

by:rehn
ID: 1866127

Ok... Yes... thanks for the 4c ;-)
Maybe "I am beating my head against a brick wall!"
But I have the same "speed limit" in much smaller and simpler animations.
So even if I am "right" and most gif viewers are "wrong" I have to yield to the fact that my animations can't be viewed by those "wrong" gif viewes. ( "right" and "wrong" in relations to available gif specifications ).


0
 

Expert Comment

by:Huafi
ID: 1866128
A suggested reason for your problem, and a suggested fix. Sorry in advance about the length:


Reason:

In images viewed over the Web (GIF, JPG, PNG, etc), image quality is sacrificed to permit a smaller file size for faster transmission.  What some people don't recognize is that once a compressed image arrives at the client's browser, it must be decompressed to its full original size. The filesize of the compressed image only affects how fast the page downloads, not how much RAM the image actually needs in the client's browser. For instance, even though I may compress a 311K, 376x282 pixel RBG (24-bit) image to, say, a 20K 6-bit GIF, once it's downloaded and rendered on a client's browser it takes up a full, uncompressed 311K of browser RAM.

My guess is that different browsers (and GIF programs) have different ways of storing and fetching decompressed images to and from RAM -- particularly with animated GIFs, which often have different physical image sizes, positions, delays, and disposal methods from frame to frame. For me (on MacOS8.5, 160mb RAM) , it took noticeably longer for NS3 to cache the image, but it displayed it very fast. NS4 started displaying the animation right away but ran it much more slowly. GIFBuilder and iCab (a "lean" German browser) both ran it at NS4 speeds. The amount of RAM allocated made no difference, so it must be inherent in the way the browser is coded -- the "speed limit" you ran into.

The bad news is that yes, you're probably beating your head against a brick wall; you'll probably never get a reliable 30fps on every browser.


Fix:

I can, however, offer a workaround. Try sampling down to 15fps as a target speed. You could probably do this by just deleting every other image from your source images and setting the interframe delay at .07 seconds. If that doesn't work, try going to 10fps by deleting 2 of every 3 images and setting delay at .10 seconds. It won't look as good, but the human eye is fairly forgiving; 15 fps looks choppy but is still perceived as continuous motion.

I read an article once that put the lower limit at 12fps (for what an average person perceives as continuous motion). With an animation like yours, though, where the motion cues are very small and very localized, I think you can get away with even less. It's with sudden, dramatic, full-screen motion that higher frame rates are called for.

The one thing that may noticably suffer will be the gunfire; it's so small and moves so fast that it will look choppy. If you are VERY VERY anal and have a LOT of time on your hands, you can help fix that problem by editing your animation frame by frame to create interpolated images that will smooth out the animation. If, for instance, you go down to 15fps by deleting every odd-numbered frame, don't just use the even-numbered frames as-is. Use a tiny bit of motion blur or frame averaging to make each frame's image of the bullets look like a timed-exposure image rather than a very crisp, high-speed image like you have now. This will smooth the transition between frames and make the animation look much smoother, if a little less crisp. You can even experiment with doing these adjustments only to certain parts of each image (e.g., the bullets) and not to others (e.g., the cockpit, HUD display, enemy planes, and landscape).


Incidentally, going with Quicktime or streaming video won't solve your problem. For those to play back at modem speeds, typically you sample down to 8-12 fps anyways, and you get bad motion compression artifacts which would render fine details (e.g., your gunfire and HUD imagery) unreadable. I think a somewhat choppy animated GIF is much better for your purposes.
0
 

Author Comment

by:rehn
ID: 1866129
I  appreciate your effort to help me, but I still need the higher frame rate for reasons I can't explain here.
 
To show the "speed limit" more clearly I have prepared a very small test animation. It is a red rectangle 200x100 pix in size. A small blue "dirty" square 10x10 pix is moving over the bigger rectangle and changing it to blue. It is 201 frames and just 9050 bytes large in all. All "speed limited" gif display programs need 11-12 s to display it. 201 / 11 = 18.27   very close too…. you guess what…. yes... the clock interrupt freq in a PC. I also discovered that I could affect ( increasing ) the playback speed in NS somewhat by moving the mouse around. Prolly caused by some extra interrupt added. This shows clearly that the "speed limit" is NOT a CPU capacity problem, it is just an artefact added by the viewer implementation.
This test animation can be found at www.canit.se/~rehn/qa0.gif ( with 0 as inter frame delay ) and www.canit.se/~rehn/qa1.gif ( with 1 as inter frame delay ). It would be interesting to know how they display on a mac.

>For instance, even though I may compress a 311K, 376x282 pixel RBG
> (24-bit) image to, say, a 20K 6-bit GIF, once it's downloaded and rendered on a client's browser it takes >up a full, uncompressed  311K of browser RAM.
Well… if that is true it very stupid thing to do, the gif image have no memory of the fact that it was a 24 bit image to begin with. The most sensible thing to do is to store it as an 8 bit dib( 106 kb ), or as a bmp in a format matching the graphics mode of the target machine.

0
 
LVL 11

Expert Comment

by:mouatts
ID: 1866130
An interesting point to note that may have some relevence to your problem is that with Netscape animated gifs cause the stop button to be illuminated imply, incorrectly, that as each cycle is completed that it is going back to the server. This isn't the case but it does suggest that the data is being stored within the cache and the animation is short circuiting the read mechanism. The effect of this will be to increase the actual effort required to animate the gif.

The second issue is that a well behaved windows program will not hog the CPU continously to display an image (or do anything else for that matter). Whilst Win 95/98/NT are preemptive this doesn't mean that a program will never yeild control volutarily. Without knowing the difference between Netscape 3 and 4 it is impossible to know if this is a factor.

Related to the above point one can assume that you will never consistently achieve the frame rate equvilent to max CPU throughput because you don't know what other processes are running and nor can you control the amount of time the foreground process recieves.


0
 

Expert Comment

by:pcarts
ID: 1866131
I'd like to see that anim GIF rehn, I could'nt get to it this morning...
I'll get back to you.
0
 

Expert Comment

by:th_c_man
ID: 1866132
I just tried to view the image and NN4.0 crashed *twice*.
This might be a problem ???
Daniel
0
 

Author Comment

by:rehn
ID: 1866133
I don't know NN4.0, but I know IE sometimes have problems with the animation qa0.gif. qa0.gif is made with 0 ms pause between frames and IE can't handle that due to a bug in IE. Try qa1.gif (10 ms between frames) or use NS.
rehn
0
 
LVL 3

Expert Comment

by:Blood
ID: 1866134
Wow is this a large thread for an animated gif =)  Your all mixing up browser functions with a display speed of a multi-layered gif89a.

Frame rate _is_ somewhat CPU dependent, but only to a small degree.  Things to factor in _besides_ gif composition are net bandwidth and available memory on the client PC.

On gif composition, there is a delay rate hard coded in the gif when it is finally written, telling the decoding viewer (if gif89a frame streaming capable) the delay in milliseconds in which to play the frames.

I have used the Microsoft Gif Animator for years, and have never hard a problem with controlling frame rate.  You do have to understand one point though; the rate itself is based on milliseconds between images, not Frames Per Second.  If you are trying to achieve a specific FPS, you will have to do some tinkering with the delay time of the images.

I checked out the image on your site and had no problem viewing it.  Is it supposed to draw pea green over red, line by line?

-Jay
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 1866135
WOW, thought surely you'd found your solution by now.  What a perservering person you are, rehn.  NN, I believe, referred to Netscape Navigator.  I rechecked the file and see what Blood reported, using IE5.
0
 

Author Comment

by:rehn
ID: 1866136
Blood:
You say " have used the Microsoft Gif Animator for years, and have never hard a problem with controlling frame rate."

OK. Please show me an animation that displayes at more than 18 fps on NS or IE....

Also, read my comment from March 1 1999
0
 
LVL 3

Expert Comment

by:Blood
ID: 1866137
Question:  What are you using to judge FPS on a picture?  Or are you simply placing 18 frames in a GIF89a and setting the delay to 0... expecting the animation to finish in 1 second?

Perhaps I stated that "quote" wrong, later on in my explanation... I mentioned that frame rate could only be controlled by image delay (based on ms).  The actual decoding and displaying of the GIF does have its limitations (viewer based.)

If you are so concerned with frame rate, why not convert the animated gif to MPEG, QTW or AVI?  I really don't see any application in which frame rate would be CRITICAL, based on an animated gif.

Also, just reading your comment on March 1st... it did raise up the point that each decode of a frame is one timeslice of the CPU.  Optimal viewing could be achieved by shutting down almost everything and NOT moving your mouse.  Each time your trackball sends a position change, the PS2 (or serial) IRQ sends a request for a CPU cycle for the update, adding another request to the queue.

Also realize that frame rate on a 2d image is controlled by the RAMDAC speed on your video card, not CPU speed.  Take for example a 640x480 animated GIF... running on a Xeon PIII 500, with a 256k video card on a 20Mhz RAMDAC.  Your CPU could handle the decoding, but your video card would show _maybe_ 1 frame every 5 seconds ?

I know of no way to encode the GIF to allow the frames to be displayed at the MAXIMUM rate of each CPU it encounters, the information coded _inside_ the GIF89a is not that complex.

Perhaps you should just wait till JPEG 2000 =)

-Jay
0
 

Author Comment

by:rehn
ID: 1866138
I am, as a test, simply placing a number of small and simple frames (qa0.gif) in a GIF89a and setting the delay to 0... expecting the animation to display at a frame rate greater than 18 fps on a 450mhz, but as I said before: all I get is 18 fps in NS and IE. This IS a viewer issue, and it seems like all viewer I have tested but NS 3.0 do have this "speed limit". I really do not need MAXIMUM frame rate, just significantly more than 18.

Yes I am working with AVI too, but the files becomes significant bigger for the same "film" (counted as bytes/frame). Animated gifs would have been perfect for my propose if it had not been for this speed limit in the viewers.

One good thing has come out of this at least, now I have learned "everything" about gif( LZW) compression and animated gifs :-)



0
 

Expert Comment

by:karenokeefe
ID: 1866139
Goodness gracious - 1065 frames! You might see some good results if you cut down the number of cells; this seems very extreme. ULead Gif Animator would be my choice for correcting any timing issues. However, I agree with other comments made - this should be in another format besides a gif animation. Why don't you try making a Flash movie instead?
0
 
LVL 6

Expert Comment

by:ckayter
ID: 1866140
Goodness gracious? Good Grief! To do this as an animated GIF, your viewers are going to need an extra 4-5MB RAM to view it! Or you'll be limited by the speed of their hard drive/swap files!

I agree that this should be a Flash movie, but MM Flash costs $$$. The only FREE movie tool I know of is MS Camcorder (included on Office CD in ValuePack folder). I don't know if it will do the speed you want, but it will create an .avi (I think that's the format... been a long time since I played with it).

Another alternative, but a large file size with 1K+ frames, would be MS Liquid Motion which would create a JavaScript and allows for setting speeds.

I'll check your site again when I get my DSL line...

Colleen

0
 
LVL 1

Accepted Solution

by:
pokemon_freak earned 450 total points
ID: 1866141
Try making the frame rate 1. the animated gifs can't go as fast as your computer. plus if the fram rate was 0, thte gif would just be a picture.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now