Basic animation

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
crowhill

Basic animation

Post by crowhill »

Hi there

Given: 0.gif, 1.gif, 2.gif, ..., 60.gif.

Seek: Animation showing 0.gif to 60.gif once and only once. Then, I wan to save the animation such that it'll play automatically when I open it.

I tried:
1. animate -delay 30 %d.gif[0-60] ... this shows the second file first and the first file at the end. Also, it loops through the sequence twice.
2. animate -delay 30 60.gif %d.gif[0-59] -loop 0 ... the order is correct but it loops through the sequence infinitely many times.
3. animate -delay 30 60.gif %d.gif[0-59] -loop n ... n is an integer greater than 0 ... again, the order is correct but it loops through the sequence n+1 times.
4. convert -delay 30 %d.gif[0-60] -loop 1 animation.gif ... gives 62 frames, the first shown one is the 62nd (62/62) and it is equal to 0.gif. The next one is the 1st (1/62) and it is again equal to 0.gif. Also, I have to use the space-bar to get through the animation, i. e. it's not automatic.

Nothing works!

Any ideas?

Thanks a lot in advance,
cheers,
crowhill.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Basic animation

Post by fmw42 »

does each 0.gif 1.gif etc have 60 frames in each of them, if not

try putting all your images in one directory (call it animation) so you can use *.gif

then

cd animation
convert -delay 30 *.gif -loop 1 animation.gif

Now when you open animation.gif in some browser it plays once (as I have verified)

You can also do:
convert -delay 30 %d.gif[0-2] -loop 1 anim.gif

and that works too

What version of IM are you using? If old perhaps you need to upgrade? I am using IM 6.6.0-6 Q16 Mac OSX Tiger

Testing:

animate -delay 30 -loop 1 %d.gif[0-2]

Does seem to loop twice! So I would suggest you report that to the bugs forum.
crowhill

Re: Basic animation

Post by crowhill »

thanks a lot for the reply!

the problems i had can be traced back to the fact that i didn't know that the resulting gif is supposed to be viewed in a browser. doing so, everything seems fine!

however, what i actually want is an animation that i can watch with a movie player such as mplayer (in linux). how can i do that? do i simply have to change the output file to animation.mpeg or animation.avi or ... instead of animation.gif?

a big thanks again!

cheers,
crowhill.

p.s.: the version i have installed is 7:6.5.1.0-1.1ubuntu3 (karmic) ... whatever that means.
Last edited by crowhill on 2010-03-18T12:30:12-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Basic animation

Post by fmw42 »

I am not really an animation expert. I know the basics for gif animations. But I have never done what you want with other movie formats, but suspect that is the case as long as you have the right delegates to create those formats. check your

convert -list format

and see if those formats have rw permissions.


see also http://www.imagemagick.org/Usage/video/

But your problem with too many loops in animate should be reported as a bug in my opinion.

I tried this:

convert -delay 30 %d.gif[0-2] -loop 1 anim.mpg

but it complained about the "ffmpeg" delegate that I guess I don't have.

So I tried

convert -delay 30 %d.gif[0-2] -loop 1 anim.mov

which did not complain, so I opened it in QuickTime and it showed only the first frame.

So I am not sure what else is needed.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Basic animation

Post by snibgo »

For animation in other formats, (.AVI, .MOV, MP4 etc) ImageMagick calls ffmpeg.

I just call ffmpeg directly:

ffmpeg -r 30 -i %02d.gif -r 30 output.avi

But the frames should have leading zeroes, so they would be 00.gif, 01.gif etc. (And I forget if ffmpeg starts at 0 or 1. Try it out, and let us know!) Any linux player should be able to play it, although some seem a bit flakey.

Type:
ffmpeg -?
for help.
snibgo's IM pages: im.snibgo.com
crowhill

Re: Basic animation

Post by crowhill »

in ffmpeg, i did

Code: Select all

ffmpeg -qscale 1 -r 1 -b 9600 -i %d.gif animation.avi
for test files 1.gif, ..., 9.gif. it works great!

thanks a lot for all advices,
cheers,
crowhill.
davezes

Re: Basic animation

Post by davezes »

Sorry for the newbie Q.

I have the exact same issue as crowhill.

But when I enter something like

ffmpeg -qscale 1 -r 1 -b 9600 -i *.pdf animation.avi

bash reports:

ffmpeg: command not found

is FFmpeg an IM dependency that needs to be installed separately?

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Basic animation

Post by snibgo »

IM uses ffmpeg as a delegate for movie operations. It isn't exactly a dependancy, but if you don't have ffmpeg, IM can't do those operations.

On Windows, IM comes with ffmpeg. On other platforms, you have to install it yourself.
snibgo's IM pages: im.snibgo.com
davezes

Re: Basic animation

Post by davezes »

Thanks snibgo,

Your info is right on target (I failed to mention I'm on a Mac).

I'm working with ffmpeg and will update this thread soon.

Many thanks!
Post Reply