Creating Animations for Presentations and the web

Elsewhere on this web site, I discuss how to create presentations and embed movies in PDF files; one question that comes up in both contexts is: how do you create animated content? One can classify animations by the same two main categories that apply to images: bitmap versus vector graphics.

Bitmap movies

The easiest and most platform-independent way of delivering animations is probably still the GIF89 movie. Other formats that are quite common are .mpeg, .mov etc. GIF animations don't require a player plugin and are therefore especially popular for web pages. The downside is that GIFs don't rpovide a play button that lets you start, stop and repeat the movie at will.

The first thing one needs is a way to produce the individual frames as bitmap images. They should preferrably be of the same dimensions (although that isn't strictly necessary in all methods described below). It is a good idea to name the frame images sequentially so that they appear in your folder listing in the order in which they are to be incorporated into the movie.

Then, we have various options to create a movie:

GraphicsMagick or ImageMagick

GraphicsMagick (fast and modern) or ImageMagick (slower but ubiquitous) are practically platform-independent tools, because you can get them for Mac, Windows and UNIX. Use the convert command to create a single GIF image. Input files can be, e.g.: PNG, JPG, GIF, BMP, or any other that the program can import. An example command with PNG input would be

(delay 3 is the shortest inter-frame delay possible).
On a Mac, you can get ImageMagick for X11 from fink. See also my general installation instructions.

Instead of creating a gif movie, mpeg encoding can also be done by simply calling
convert -quality 100 *.png Outputfile.mpeg

Quicktime via QTKit library

To make .mov files that can be displayed by Quicktime Player, you can use the Python script that I list on the page "Frame-by frame animation as Quicktime with variable frame duration". The special feature of that script is that it lets you set individual frame durations for each image in the sequence. Such a variable frame rate is useful for animations when you want to slow down or pause at certain frames, without copying the corresponding image and thereby increasing the file size.

iMovie

On the Mac, we of course also have iMovie. The main obstacle with all versions is that there is a minimum frame duration that is too long for most animations. For iMovie HD,
there is a work-around that allows to go down to 0.01 second frame duration. That's more than enough for normal applications. Instructions for how to use iMovie '09 are on a separate page. The .01s frame duration seems to be unachievable with iMovie '09: whereas it lets you freely speed up or slow down movie clips, the frames in a slide shows are limited to .05s with my settings. The way to get around this is relatively simple: just export a slow version of your animation first (dictated by the minimum still image duration), then re-import the resulting movie clip and change its overall speed by an arbitrary factor.

Blender

To assemble image sequences into movies or deconstruct movies into images, you can also use the 3D design program Blender. This linked page explains how to utilize Blender's Video Sequence Editor.

GraphicConverter

There are two simple ways of creating animations with GraphicConverter, the powerful graphics editor that used to be bundled with OS X and is now shareware.

Choose File ⇒ Convert&Modify .... Follow the instructions in Chapter 9 of the GC Help document, to end up with an animated GIF.

Choose File ⇒ Export Slide Show to Movie .... You'll have to navigate to the folder containing the images. After choosing some settings, GraphicConverter will create a file with the extension .mov. This file format is suitable for inclusion in Keynote, for example.

Other routes

Here are some other alternatives for creating bitmap-based frame animations:

To create a gif movie from an image sequence, there is also the free utility GIFFun.

To convert an image sequence to a movie, first make sure the images are strcitly named in a consequtively increasing numerical order, starting with 1 (for example, a1.jpg, a2.jpg etc.); then do, e.g., ffmpeg -f image2 -i a%d.jpg b.mp4. The numerical part of the files has to start at 1. If you need multiple digits, say 001 and so on, then replace %d by %03d. To maintain the exact quality of the input images, do ffmpeg -sameq -i %03d.jpg output.mp4.

On Mac OS Leopard, the built-in Python interpreter has the ability to call the Quicktime (QTKit) functions via PyObjC. Using this, you can build your own movie programs in Python without downloading anything. Of course, this has been done already, and the result can in turn be downloaded as an AppleScript Application (the script doesn't work without modifications on Tiger).

To convert from Quicktime .mov to .mpeg, one can use QT amateur, a free movie player for Mac OS X which can export various movie and image file formats (even in batch mode). It requires Quicktime 7 to be installed on your machine.

Apple's Quicktime Pro application has more flexibility but it's not free.

If you are comfortable with command-line UNIX tools, there are the free packages mpeg2vidcodec or mpegencode, available for Mac from the porting system fink.

Many mathematical software packages like Mathematica and Maple are able to create image sequences that can be exported as animations. However, I usually want more flexibility and therefore export the individual frame images from those programs, followed by movie conversion using one of the tools mentioned above.

Animated PNG

An important limitation of GIF movies is that they only permit up to 256 colors, and a one-bit alpha channel (for transparency effects).

That's why in Firefox 3 (as well as Opera 9 and Camino 2) support an extension of the PNG format that allows multi-frame animation. Demos of these animated PNGs show that gradients in colors and opacity are rendered very well. Browsers that don't support the new format will see only the first frame of the animation. To create animated PNG, a nice tool has been implemented in Java: JAPNG. An easy-to-use online application is the APNG Assembler. Of course there are also Firefox add-ons, e.g.,
Animat. Even more than with GIFs, the problem with this animation format is that the file size gets very large.

Vector animations

Vector formats are especially practical when you're interested in objects that can be described efficiently using strokes, fills, gradients using only a few control points.
The main formats for vector-based movies on the web are SWF (Flash) and SVG (Scalable Vector Graphics).
If you have Adobe Illustrator, both of these file formats can be created quite easily. Here is an example I created by drawing a mere four shapes and telling Illustrator to calculate a blend between them:

With these interpolation capabilites, Illustrator is very useful for creating hand-drawn animations.

All you need to know is how to blend your key sketches together and make a movie sequence out of the intermediate steps: The Make Blend command in Illustrator creates a compound object that needs to be disassembled by choosing Expand from the Object menu. This creates a number of objects that may still have to be ungrouped, and each of these then represents one frame in your animation. The next step is to place all these objects into one otherwise empty layer, select that layer in the Layers palette, and choose Release to layers. This creates a sequence of new layers, one for each animation frame. Finally, choose File ⇒ Export for Web and select SWF as the file format. The option Layers to SWF makes the SWF into a movie.

The file size of the Flash animation above (8 kB) is still significantly smaller than even the reduced-size GIF movie shown below (36 kB):

Interactive vector animations

With Flash, one has a format that allows much more than movie playback. The Flash Player engine is used for internet games and user interfaces.

Here's a piece of art called "Don't Stick":

It was created using Flash and ActionScript 3 by my son James Nöckel (December 24, 2007). Try to keep the vehicle from touching the walls by steering with the arrow keys. If you manage to get to a double-digit score, you're a master.

There has been some controversy over Flash, partly over security concerns and partly because it is perceived as the medium responsible for most of today's web advertising nuisance. However, security concerns also exist with other, "newer" technolgies that are being incorporated into browsers, such as WebGL. Flash ads are annoying, but to dismiss Flash because of this would be a naive fallacy: any technology that can replace Flash will also eventually be used for advertising. Browsers can block Flash ads from sites you don't like, but are powerless against ads based on HTML5/CSS/JS animations. In the near future, we may well find ourselves longing for the good old days whan ads were confined to Flash objects.

The main valid objection to Flash is that it requires a plugin that can put additional load on the processor. This is true because all vector graphics, and especially Flash files, are more or less complex programs that must be executed by the plugin. The tradeoff between higher processor load and small file size for Flash objects means that bitmap animations may sometimes be preferable.