creating an animGIF with 30 FPS?
creating an animGIF with 30 FPS?
Hi,
I was trying to create an animated GIF at 30 FPS, so playout is mostly synchronized with the typical LCD refresh rate of 60 Hz.
convert.exe -delay 1x30 -loop 0 image%03d.pgm[0-1199] image.gif
GIF specifies the delay between frames in 1/100th's of a second. So I find that the generated 1200 frame animation replays at faster frame rates because the delay it introduces between frames is always 3/100ths of a second, resulting in 33.33 FPS
Is there a way to accomplish that ImageMagick uses 4/100ths and 2x 3/100ths seconds delay for each three consecutive frames, so that the average delay becomes 33.333ms and I do get 30 FPS exactly?
Christian
I was trying to create an animated GIF at 30 FPS, so playout is mostly synchronized with the typical LCD refresh rate of 60 Hz.
convert.exe -delay 1x30 -loop 0 image%03d.pgm[0-1199] image.gif
GIF specifies the delay between frames in 1/100th's of a second. So I find that the generated 1200 frame animation replays at faster frame rates because the delay it introduces between frames is always 3/100ths of a second, resulting in 33.33 FPS
Is there a way to accomplish that ImageMagick uses 4/100ths and 2x 3/100ths seconds delay for each three consecutive frames, so that the average delay becomes 33.333ms and I do get 30 FPS exactly?
Christian
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
- Contact:
Re: creating an animGIF with 30 FPS?
I believe this is correct, though not 100% sure. delay=1 is 1/100 sec per frame. So delay=100 = 1 sec per frame. So delay= 100/30 = 1sec/30frame. So you need a delay of 3.33 (100/30) to achieve 30f/sec.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
- Contact:
Re: creating an animGIF with 30 FPS?
P.S. if IM does not like fractional delays such as
-delay 3.33 (-delay 3.33,100)
then you can scale the delay and tics per second, such as
-delay 33,1000
0r
-delay 333,10000
-delay 3.33 (-delay 3.33,100)
then you can scale the delay and tics per second, such as
-delay 33,1000
0r
-delay 333,10000
-
snibgo
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
- Contact:
Re: creating an animGIF with 30 FPS?
From http://www.imagemagick.org/Usage/anim_basics/ :
In practice, you could build the command in a script, reading each frame from one animated gif, writing to another gif.
It seems the metadata is stored in units of 1/100s, so "-delay 33x1000" etc will result in 3/100.GIF animation delays must be specified in hundredths of a second for correct working, which is why that is the default time unit.
Sure. Just list the frames with a "-delay" between them, eg:cbuchner1 wrote:Is there a way to accomplish that ImageMagick uses 4/100ths and 2x 3/100ths seconds delay for each three consecutive frames, so that the average delay becomes 33.333ms and I do get 30 FPS exactly?
Code: Select all
f:\web\im>%IM%convert -size 100x100 -delay 4 xc: -delay 3 xc: xc: x.gif
f:\web\im>%IM%identify -verbose x.gif |cgrep /i- /o- /sDelay
Delay: 4x100
Delay: 3x100
Delay: 3x100snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
- Contact:
Re: creating an animGIF with 30 FPS?
Thanks, snibgo, for posting that. I had never knew that before. I see it now in the reference link you provided. I was only looking at -delay from the options page information.snibgo wrote:GIF animation delays must be specified in hundredths of a second for correct working, which is why that is the default time unit.
Learned something new today!
I assume tics must be integers. Do you know if that is true?
-
snibgo
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
- Contact:
Re: creating an animGIF with 30 FPS?
I haven't looked at the GIF spec or IM's code, but playing with commands like ...
... I find the delay parameter is always rounded to an integer number of hundredths.
Code: Select all
convert -delay 3.6 -size 100x100 xc: -duplicate 100 x.gif
convert -delay 36x1000 -size 100x100 xc: -duplicate 100 x.gif
snibgo's IM pages: im.snibgo.com
- glennrp
- Posts: 1147
- Joined: 2006-04-01T08:16:32-07:00
- Location: Maryland 39.26.30N 76.16.01W
- Contact:
Re: creating an animGIF with 30 FPS?
Actually it's truncated to an integer. -delay 1x30 and -delay 39x1000 both write a GIF with delay 3, while -delay 40x1000 writes delay 4.
-
snibgo
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
- Contact:
Re: creating an animGIF with 30 FPS?
True, "-delay 39x1000" becomes 3*. But (in v6.9.0-0) "3.9" becomes 4.
*EDIT: I wrote "4" but meant "3".
*EDIT: I wrote "4" but meant "3".
snibgo's IM pages: im.snibgo.com
- glennrp
- Posts: 1147
- Joined: 2006-04-01T08:16:32-07:00
- Location: Maryland 39.26.30N 76.16.01W
- Contact:
Re: creating an animGIF with 30 FPS?
Right. The components of 39x1000 are rounded in constitute.c to 39 x1000, and 3.9 is rounded to 4 Then in gif.c the
integer calculation of 100*39/1000 yields 3 while the integer calculation of 100*4/100 yields 4.
integer calculation of 100*39/1000 yields 3 while the integer calculation of 100*4/100 yields 4.
Re: creating an animGIF with 30 FPS?
Wouldn't it make sense to accumulate that rounding error, so that consecutive frames of an animation might use different delay values?
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 6 guests