Converting a Sequence of rgb files to MPEG

Abstract
A brief description of the steps required to convert a sequence of image files in SGI's rgb format to an mpeg movie is given. It is assumed that you have a number of image files that you would like to convert into a movie. The method discussed converts the image files to mpeg using the mpeg_encode program which is available at s2k-ftp.cs.berkeley.edu.

Local note: If you are on UNH's spice machines we already have all of the conversion programs installed.


Required Conversion Programs

The conversion routines discussed here use the mpeg_encode program. A copy of the program can be found at s2k-ftp.cs.berkeley.edu. To use this conversion utility you must be able to convert your image files to either ppm, pnm, or yuv format. If you do not have the netpbm conversion utilities you may need to install them. The necessary files can be found at ftp.cs.ubc.ca.

File names for the image files.

Before encoding you must first have the image files that you would like to convert to mpeg. To let the encoder know the correct order you can specify the files in a couple of different ways. The easiest way is to generate a sequence of image files which are numbered sequentially. For example, for the incompressible flow within a driven cavity I have generated the images showing the pressure at the time steps 0 through 295. The file names were generated using pressure####.rgb where #### is the number of the time step:

pressure0.rgb
pressure1.rgb
pressure2.rgb
...
pressure35.rgb
pressure36.rgb
pressure37.rgb
...
pressure294.rgb
pressure295.rgb

There is one problem with this arrangement if you are working on an SGI workstation. The movieconvert program that is now part of OS 5.3 requires file names where the numbers are in fixed field. For example, the pressure field at the 35th step should be in a file called pressure35.rgb, but in your program you generated the file and called it pressure0035.rgb so that you could use the movieconvert program. Since the program converts to quicktime and not mpeg you may want to create two movie versions (or use mpeg since it compresses MUCH better). To convert file names from the SGI format to the format that mpeg_encode prefers try this perl script that we use. You can then use mpeg_encode on the new sequence of files.


Converting the Files

Once you have the image files and have installed the conversion software the conversion process itself is not too complicated. Before the conversion can take place, however, you must specify the files and certain parameters for the conversion process. Since the files are assumed to be in rgb format you must also specify how each file is to be converted. We have found that the simplest way is to use the sgitopnm program found in the netpbm distribution.

The parameters that are used in the conversion process are specified in a separate file. The file must follow a very specific format. For an example of the format file see pressure.param. We have found this to give decent results. Because we used small numbers for IQSCALE, PQSCALE, and BQSCALE the compression is not as tight as some would like. However, it does offer relatively sharp output. Of course, your mileage will vary!

The parameter file pressure.param, does the following things:

  1. Output will be an mpeg file called pressure.mpeg
  2. Files will be found in directory ./plot/base
  3. Files will be called pressure0.rgb through pressure295.rgb.
  4. The image files will be converted to PNM format
  5. The image files will be converted with the command sgitopnm
Play with remaining parameters to get the movie you are looking for. Be sure to make RANGE divisible by SLICES_PER_FRAME. To increase the sharpness of the images make IQSCALE, PQSCALE, and BQSCALE smaller. To increase the efficiency of the compression increase these variables.

Once all these things are in place and you have a parameter file (pressure.param) you can encode your files with the following command:
mpeg_encode pressure.param

After you have gone out for a cup of coffee you will find a new mpeg file.

Warning The parameter file given in this example seems to do a better job of generating sharper images than the parameter file that is given in the gif to mpeg tutorial. The downside is that it uses more memory. Look at both and compare for the best results.


Bibliography

Graphics and Visualization Lab Manual, Army High Performance Computing Research Center, University of Minnesota.

mpeg_encode man pages.

MPEG Technical Info, Honolulu Community College's Web Site.
Kelly Black