|
|
This document is available in: English Castellano Deutsch |
by Alexander Langer <lf(at)kuxi.de> About the author: I'm using Linux since 1993. Coming from the Amiga, I like that you can get the source code for everything and find out how others do it in their programs. Content: |
Simple AnimationAbstract:
Creating a simple animation is fun and easy, for children and adults alike. Possible types of animation include simple object animation, Monty Python-style animations, time-lapse films, clay animation a'la Wallace&Grommit and many more. In this article we will not create a full film. Using a very simple example you will lean the basic techniques. Just enough to start your own movie ;-). Note: The picture on the right and the little dot above are animated.
You need to enable gif-animation if you want to see them in your
browser.
|
Regardless how you plan it, the next step is to acquire the single frames of the animation. Optionally you post-process them or add frames with text, just like in the old Stan-and-Ollie movies.
Last, you merge the single frames into a movie.
To edit the frames, you can use Gimp or any other painting program.
ImageMagick (www.imagemagick.org), the Swiss Army
Knife of programs to convert and display images, is very useful to
display and create animations.
If you don't have a camera, no problem, we'll make a "jumping-dot" animation. Start Gimp and select File->New. Click "OK" to get a default 256x256 image with white background. Select the brush tool in the main window and click somewhere in the lower left area of the image to produce a dot. Right-click into the image, select File->SaveAs and save the image as "0001.jpg" into an empty directory. Just click "ok" in the JPEG-options screen. This is the first frame. Let's say we want 10 frames, thus repeat the following 9 times:
You should now have something like this:
Now we create the movie:
$ mencoder 'mf://*.jpg' -mf type=jpg:fps=4 -ovc copy -oac copy -o output.aviThe parameter "fps" specifies the "frames per second" value. Lower numbers mean less work for you, but a more jerky animation.
To watch your masterpiece, type:
$ mplayer output.aviIf you want to experiment with different frame rates you can do that with mplayer's "-fps" option, for example to force 10 frames per second, use "-fps 10". It's not necessary to encode the animation again with a different frame rate unless you want to give it to somebody else.
Especially for short clips it's often handy to use the "-loop" option, for example "-loop 10". This will play the clip ten times.
Alternatively to using mencoder/mplayer, with the animate program from the ImageMagick you can preview the clip:
$ animate *.jpgIt plays the clip continuously. If you left-click into the animation a menu will open. You can use the Space and Backspace keys to single-step through the animation (the filename of the current frame is shown in the title bar of the window, useful if you want to touch up a single frame). To change the speed of the animation, use the "<" and ">" keys.
Now press CTRL-v and select the Move-tool (its icon is arrows in all four directions). Move the chin where originally was. Save the picture as 0001.img, just as you did with the jumping dot, click on "Export" when Gimp complains that JPEG cannot handle transparency. Move the chin a little down and SaveAs 0002.jpg. Continue until you have all the frames. Then encode with mencoder. You'll get bonus points for lip-sync to music or a speech audio track.
If you want to encode to an animated GIF (like the image at the top of this article), ImageMagick's convert program does that:
$ convert -delay 20 *.jpg out.gifThe "-delay" option is in 1/100th of a second, thus 20 equals 5 frames per second. By the way, you can see the single frames in the animated GIF with "identify":
$ identify out.gif" out.gif[0] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[1] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[2] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[3] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[4] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[5] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[6] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[7] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[8] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[9] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01 out.gif[10] GIF 152x104+0+0 PseudoClass 256c 8-bit 201.1k 0.0u 0:01
If you shoot automatically, you can afford the luxury of a high frame rate, as long as your free hard-disk space permits.
What to film?
If you decide to take pictures of your child growing, my conclusion is that 6 months should be often enough to get enough pictures without being too often to not do it. If your baby is born in summer, you can take birthday and Christmas photos :-) The other conclusion I had is to take the picture always so that 2m are shown in the photo, to have the same scale for all the photos. Otherwise you have to scale them yourself.
Re-do Pixar's Luxo Jr. (www.pixar.com/shorts/ljr/) with your desk lamp and a ball.
Let's say you want to add a balloon, to make a person or figure say something. Instead of using steps of "1" for the image names, use steps of "10" when you shoot the frames. Load the frame to which you want to add the balloon into Gimp. Draw the balloon and add the text. Save the frame and exit Gimp. Now, duplicate (copy the file) the frame 9 times, give them the numbers between the current and the next frame. If you have programmed BASIC during the 80ies you remember this technique :-) When you encode this, the frames with the balloon will be shown for a longer time, long enough that it's possible to read the text. With the same technique you can insert a new frame as they did in the silent movies at the beginning of the 20st century.
You will soon wish to be able to see the previous frame(s) overlaid over the live camera picture (called "onion skin"). With that you can better align the position of moving objects, improving the illusion of motion. The Gimp Animation Package looks promising for this purpose.
Webpages maintained by the LinuxFocus Editor team
© Alexander Langer "some rights reserved" see linuxfocus.org/license/ http://www.LinuxFocus.org |
Translation information:
|
2004-10-15, generated by lfparser version 2.50