CS155 Movie FAQ


Here's all the info you'll need to make movies for bonus points in CS155. The general technique is to use a script to generate a number of images from a template file, and then pass these images to mpeg_encode to create your final movie file.

mpeg_encode is a tool produced by a research group at Berkeley to create MPEGs out of multiple image files. The program can be found at /cs/cs155/movies/mpeg_encode . It has a complicated interface however, so it's explained in detail here.

Additionally, to make the process of creating a sequence of images easier, we've provided you with a few scripts for use with projects 1, 2 and 3 that will take a template and a configuration and make all the images.

A quick aside note - to view mpegs on the graphics machines, use mtv for a player with a user interface, or mtvp for a simple player without an interface.


mpeg_encode

usage: mpeg_encode paramfile

mpeg_encode gets all of its options from a parameter file specified on the command line. This file contains the name of the output file, the input directory and file pattern, the input format, and a variety of options that control the level of mpeg compression. For most of these values, the default is adequate, and so they will not be explained here. For a better understanding of mpeg compression and the controls mpeg_encode provides, visit the mpeg_encode website.

Here is what an example parameter file looks like. This file is available here.

   PATTERN i
   OUTPUT move.mpg
   INPUT_DIR .
   INPUT
   image_*.ppm [01-10]
   END_INPUT
   BASE_FILE_FORMAT PPM
   INPUT_CONVERT *
   PIXEL FULL
   GOP_SIZE 1
   PQSCALE 1
   IQSCALE 1
   BQSCALE 1
   RANGE 5  
   PSEARCH_ALG LOGARITHMIC
   BSEARCH_ALG SIMPLE
   SLICES_PER_FRAME 1
   REFERENCE_FRAME ORIGINAL

The second line sets the name of the output movie file. The third line specifies the directory to look in for the input image files. All images must reside in the same directory.

The fifth line specifies the pattern for the input image file names. The first string ( image_*.ppm ) is the name of the files, with a * where the frame number should be. The second string (< tt>[01-10] ) is the range of values the frame number can be. In this case, the input files image_01.ppm to image_10.ppm will be used. mpeg_encode will also make sure to match the zero-padding of the range values. In this example, since the beginning of the range is padded to two digits, mpeg_encode will pad all frame values to two digits. If the range were [1-10], mpeg_encode would not pad any of the frame values. More complicated input patterns are possible - to learn about them, visit the mpeg_encode website.

The seventh line specifies the format of the input image files. mpeg_encode only supports a limited variety of image formats, so we recommend sticking with PPM. If your images are in a different format, use convert (on the graphics machines, man convert) to make them into PPM files.


Scripts

To help with the movie submissions for each project, we've created scripts that take a template input file and a configuration file, and write a sequence of images which is passed to mpeg_encode for movie writing. These scripts all use the same basic techniques, but are adapted to each project's interface. The scripts can be found in /cs/cs155/movies/ , in subdirectories ipmovie, rtmovie and glmovie. usage: ipmovie.pl ip_binary [ config ]
usage: rtmovie.pl rt_binary [ config ]
usage: glmovie.pl gl_binary [ config ]

The files for each script are basically the same. There's the __movie.pl file, which is the perl program that does all the work. It reads in config.pl, which stores the configuration for the animation in perl. If a config file is specified to the movie script on the command line, that file will be used - otherwise, the movie script will search for config.pl. Finally, there's the input template (like example.ray), which maintains the basic format of each program's input, but has variable names (like SPHERE_X) in place of some values. The movie script will create an input file for each frame of the animation, with all the variable names replaced by values particular to each frame. The number of frames and values of the variables are controlled by the config.pl file. Once the input files are written, the movie script runs the executable (ip, rt, or gl) on each input and saves the resulting images. These images are converted to PPM format and passed to mpeg_encode for final movie creation.

For each script, look carefully at the example input and config.pl to make sure you understand what's going on before creating your own animation. Follow the format of the examples and you shouldn't have any trouble.

One important detail to note about variables in the input template, there are two special variables provided by the movie scripts. SOURCE and DESTINATION contain the paths to the source and destination files for each frame. These are useful (specifically DESTINATION) for ipmovie.pl, since an ip script needs to save the file to some destination before quitting. Look closely at the ipmovie example.txt to see how DESTINATION is used.


Last Update: 7/23/02