Stop-Motion Animation Tutorial

using the shell commands mogrify, animate, and ffmpeg

Preparing the images

Images can be captured or generated in a variety of ways. One example would be a sequence of scanned hand-drawings; another would be screen-captures of a drawing created in a computer program, from GIMP, Photoshop, Inkscape, Illustrator, or a CAD program. A third source would be a series of digital camera photographs of a set in which figures are moved incrementally between photographs.

In all cases, the sequence of images may need to be reduced in size and color depth to reduce file-size. Whereas a scanner or camera may capture images at 2000x3000 pixels, a typical YouTube animation is perhaps 640x360 pixels. Consider your final output size, requisite image quality, and the processing power of your computer. Working with smaller file may save you a lot of working time.


I am on Linux (Ubuntu), and I use shell commands to batch process the images. The commands some from the suite “imagemagick”. To install these shell utilities on an Ubuntu system, enter:

sudo apt-get install imagemagick

Then you can use batch processing commands such as mogrify. Navigate to the directory of images you will process, which should not contain any other files. Execute:

mogrify -verbose -resize 600x400 -quality 60% *.jpg

(You can also use mogrify to batch-convert file formats, but that is not necessary here.)

However you obtain, process, and crop images, the end result should be a directory with a sequence of images in it.

Preview the sequence with animate, another command from the imagemagick package:

animate -delay 10 *

From this you can make more editing decisions.

Rename files into a regular sequence starting from (0000)1

Your sequence of images probably starts with a filename like: DSC07648.jpg. If you have removed some images from the sequence, it may still be ascending-order but discontinuous. To stitch together separate still-frames into a movie using ffmpeg, the numbering in the file series will need to begin with 1, or some value equaling 1 such as 00001, which is 1 with five digits overall in the filename. To do this I will use a shell script, renumber_from_one.sh (linked here) which renames a file list such as:

DSC07648.jpg

DSC07651.jpg

DSC07652.jpg

DSC07653.jpg

...etc

To:

DSC00001.jpg

DSC00002.jpg

DSC00003.jpg

DSC00004.jpg

...etc

Stitch together using ffmpeg

The syntax of ffmpeg is:

ffmpeg -r [input-FPS] -i [infile] -f [out format] -r [out-FPS] -s [(width)x(height)] [outfile].[filetype]

In this case:

ffmpeg -r 4 -i DSC%05d.jpg -f flv -r 4 -s 600x400 dino_stopmotion3.flv

ffmpeg -r 4 -i DSC%05d.png -f flv -r 4 -s 534x400 dino_stopmotion3.flv

This produces an .flv file which is 1.1 MB; this is the format, resolution, and compression typical of YouTube files.

NOTE: the original file was 533x400, but ffmpeg requires a even-numeral pixel size. So I changed to 534x400; this worked, but it would be better to start with even-numbered pixels at the beginning.