Page 1 of 1

How to speed up animated GIF

Posted: 2012-02-22T07:37:19-07:00
by fibonacci1101
Hello everyone ;)

I know the topic of my post seems familiar and there is a lot topics like this but none of them could help me solve my problem.
So, I'm converting a group of images into animated GIF, that I've extracted from video file, using this command:
convert pics-*.png -resize 500x281 animated.gif
And in the result I get animated GIF that is runing with the same speed as video file is. I suppose that this command is using by default -delay 0.
But I want to make my GIF even faster. Is there a way to do this using ImageMagick?
The only way I dicovered was to firstly convert the video file using ffmpeg and this command:
ffmpeg -i video.mp4 -f yuv4mpegpipe - | yuvfps -s 100:1 -r 100:1 | ffmpeg -f yuv4mpegpipe -i - -r 25 -y output.mp4
which is speeding up the video file 4x, then using this command:
ffmpeg -i output.mp4 -f image2 pics-%04d.png
to extract all the frmaes from speeded up output file and then convert them to GIF using command "convert"
Is there any faster and easier way to do this?
What I want to do is to do this without speeding up the video file, just extract frames from original video file and speed it up using "convert" command.
Something like this: convert pics-*.png -resize 500x281 "-here some command speeding GIF up" animated.gif
Is there any way to achieve it? Please, help me solve my problem ;)

Re: How to speed up animated GIF

Posted: 2012-02-22T10:41:19-07:00
by fmw42
I believe that gif animations may have some minimum delay. But even if not, the viewer usually imposes restrictions of its own. Different viewers will give different speeds even when the -delay from IM is 0. However, I will defer to those more experienced with animations than me.

Re: How to speed up animated GIF

Posted: 2012-02-22T12:27:53-07:00
by fibonacci1101
It's not about changing delay because I believe that delay 0 is the lowest and gif cannot animate any faster. It's more about morphing/joining frames and by it reducing the numer of frames but maintaining the fluency/smoothness of the animation.Is there any command that can do it? Any help?

Re: How to speed up animated GIF

Posted: 2012-02-22T13:13:36-07:00
by fmw42
fibonacci1101 wrote:It's not about changing delay because I believe that delay 0 is the lowest and gif cannot animate any faster. It's more about morphing/joining frames and by it reducing the numer of frames but maintaining the fluency/smoothness of the animation.Is there any command that can do it? Any help?

Still not sure what you mean, but IM has -morph. See http://www.imagemagick.org/script/comma ... .php#morph and http://www.imagemagick.org/Usage/anim_mods/#morph

Re: How to speed up animated GIF

Posted: 2012-02-22T14:00:23-07:00
by fibonacci1101
I mean morphing like joining few frames into new one. So if originally GIF is consisted of, let's say, 60 frames than after converting it with IM it will be 40 frames for example. I don't know how to explain it better, maybe I will prepare some GIFs and show them to you later.

Re: How to speed up animated GIF

Posted: 2012-02-22T15:17:34-07:00
by fmw42

Re: How to speed up animated GIF

Posted: 2012-02-22T16:26:57-07:00
by fibonacci1101
Ok, I came up with this idea. While extracting frames from video I'm using this command:

ffmpeg -i input.mp4 -f yuv4mpegpipe - | yuvfps -s 75:1 -r 75:1 | ffmpeg -f yuv4mpegpipe -i - -r 25 -y -f image2 output-%04d.png

So it's like speeding up video first and then extracting it frames, but without genereting new video file. In result I'm getting aproximetly every third frame from the input video file. And then I can make a gif from extracted frames using "convert".

But the "-delete" formula seems to work too. It can be used when the GIF is already made so you can remove every second or every third frame from it to make it look faster.

If anyone will come up with better formula please let me know ;)

Re: How to speed up animated GIF

Posted: 2012-02-23T19:17:41-07:00
by anthony
fibonacci1101 wrote:I mean morphing like joining few frames into new one. So if originally GIF is consisted of, let's say, 60 frames than after converting it with IM it will be 40 frames for example. I don't know how to explain it better, maybe I will prepare some GIFs and show them to you later.
Removing frames is a matter of coalesing the animation, and removing say every second frame. Their is no simple automated way to do this in ImageMagick, at least not at this time. A shell wrapper, or image pipeline such as described in the 'video' solution above, could do it. Note I doubt even IMv7 improved CLI could do this directly in IM itself.


Note the cartoon artists also had similar problems, making a character move quickly from on place to another when you can't use enough frames to show that movement. Their solution was one intermediate 'blurred' frame.
For example... This is only 4 frames!
Image