Converting ppm files to mpeg

From Gerris

Jump to: navigation, search

As suggested in the tutorial [1] multiframe ppm image files can be converted to mpeg format using Imagemagick's [2] convert [3] program with

 $ convert vorticity.ppm vorticity.mpg

which in Bash can more compactly be expressed

 $ convert vorticity.{ppm,mpg}

For this to work, one needs imagemagick (from the Debian package of the same name, for example) and also mpeg2encode which doesn't have a Debian package. Following some instructions from Marshall D. Perrin [4], the source code for the program can be found on the imagemagick site at ftp://ftp.imagemagick.org/pub/ImageMagick/delegates/mpeg2vidcodec_v12.tar.gz. This is compiled with make, and then the executable has to be copied to a directory on PATH (or its directory added to the path).

 $ tar xzf mpeg2vidcodec_v12.tar.gz
 $ cd mpeg2
 $ make
 $ sudo cp src/mpeg2enc/mpeg2encode /usr/local/bin
 $ sudo cp src/mpeg2dec/mpeg2decode /usr/local/bin

The resulting MPEG file can then be played with Totem [5], mplayer [6], &c., or with Imagemagick:

 $ animate vorticity.mpg

As suggested in the tutorial, the MPEG file is much smaller than the PPM; here it's 1.9M cf. 85M.

Personal tools
communication