Making MPEG movies with Partiview

The Teuben-Levy manual explains how to created animated gifs with Partiview. The way they do it is a great example of the async command.

Unfortunately, animated gifs are large and clunky. Here's how one can make mpeg's with Partiview on linux. Well, how to make them in MPEG-1 format anyway. You can convert this to other formats using Transcode (thanks to Selden Ball for the pointer to it.)

This page also has details on making stereo movies.


Get the following software:

You also need /bin/sh, awk and perl, but these are standard on linux systems.

Once you have the above, save and unzip it in a new directory. It has the perl scripts mentioned in this document and a copy of make_mpeg2encode_parfile.

This is enough to make mpegs. It's not enough to view mpegs. For that you need a viewer. I found the MpegTV player easy to setup, even on a machine where I wasn't root.

How-To's makes a file of the above type. You use it from the command line (before you even touch Partiview) like this:

   Usage:  perl execfile N [E]

   execfile = the executable file you can call with 'async execfile' in Partiview.
   N        = the number of snapshots this will take.
   E        = once every how many snapshots it Partiview reports a location using 'where'
                while recording. If not supplied, no locations are reported.

This creates an executable file execfile (make sure you can change group permissions in the directory where execfile is!) with N statements of the form

echo step 0...  
echo update
echo snapshot

The "step 0" is just there to slow things down. You may want to remove it. If your data is animated, you'll need to use "step n" for displaying data at the n-th timestep.

If E is specified, it places an 'echo where' every E 'echo snapshot' statements.

How large should N be? MPEGs by the process listed here get made at, by default, 15 or 16 frames per second. Decide how many seconds you want, and multiply that by anything larger than 16.

Choice of E: Specifying E allows you to tell where the Partiview camera was during the recording, in case you mess up (I mess up a *lot*) while recording. I've set it to 25, which produces satisfactory enough animations. However, if you look carefully, you'll notice the slight jerks every one and a half seconds.

cd to a directory where you have write access. All intermediate image files, and a few others, are going to be saved here. Remove any .sgi files already here.

   perl movie2000 2000 

Once this is done, fire up Partiview with your data set. Press tab and say "winsize M N" (e.g. "winsize 1024 768") to get M by N pixel pictures.

When you are ready to record, press tab and type "async movie2000". Then move around. (Moving around before you start recording is sometimes a good idea.) Every (?) milliseconds a snapshot will be taken. It certainly won't be at a rate of 16 per second, so make sure you move quite slowly. Make a few small movies to get a feel of this.

Added, 4 Feb 04, Making movies of prerecorded flypaths.

Caution: don't let anything else get in front of the Partiview screen, screensavers included, while Partiview is getting these shots! You can have Partiview not take up the whole screen - that's quite fine. Only the stuff within Partiview's part of the screen is recorded.

When 2000 (in general, N) snapshots have been taken, Partiview keeps running. If you havent finished recording, pressing tab and saying 'async movie2000' will get another 2000 snapshots. Partiview remembers the number of the last snapshot it took and starts from 1+there, so no worries about overwriting.

As always, you can exit Partiview before it finishes taking snapshots by pressing ESC.

Then say

perl whatever.mpeg snap.*.sgi
Assuming all goes well (e.g. you don't run out of disk space), [Corrected modification by Ashlesh Sharma posted on Nov 27 05 - thanks! - old version (for reference)] creates the MPEG-1 file whatever.mpeg out of all the snapshot files snap.*.sgi . And yes, they are always called snap.*.sgi - it's a Partiview thing. The program also creates a set of .yuv files for each of the .sgi files you have. These can be removed if all goes well.


You can skip this section unless you want to know what's going on.

The recording process results in a series of files of the form (for xxx = 000 to 999) and snap.xxxx.sgi (for xxx > 1000). I've never taken got anywhere near 5 digits, but presumably that's snap.xxxxx.sgi. Since snap.1234.sgi comes before snap.234.sgi in the usual filename ordering, you have to rename each file as snap.0xxx.sgi.

So the first thing does is (equivalent to) giving the shell command

 perl 4 snap.???.sgi comes with the other scripts in It just issues a bunch of "mv snap.0abc.sgi" statements.

Now all files are of the form snap.????.sgi . Further modifications to are required if you're putting together more than 10000 images! then converts each of the snap.????.sgi files to the corresponding snap.????.yuv file using 'convert', the ImageMagick utility. Note that both .sgi and .yuv files are huge (of the order of a megabyte for a 1024x768 pic) as they use very little compression. The latter are a intermediate file format (.ppm is the other) for making mpegs. then uses make_mpeg2encode_parfile with the command

make_mpeg2encode_parfile snap.*.sgi

This creates, in the same directory, a file called mpeg2encode.par, which has options used to make the MPEGs. Note that it refers to snap.*.sgi, not snap.*.yuv . This is what you want to modify if you'd like to change some mpeg making options. However, I don't understand it. For instance it claims that the frame rate per second is 1, which is certainly not true. then calls

mpeg2encode mpeg2encode.par whatever.mpg

This makes the mpeg file. Don't worry if it burps at the end, giving some message about not being able to find some file.


Regular Expressions

File names can be regexped to some extent. * means 'anything', ? means single character and [a-b], where a and b are digits, means every digit between a and b inclusive. So snap.4[2-4]?.sgi refers to all files between snap.420.sgi and snap.449.sgi inclusive. I'm not sure if saying "perl argh.mpeg snap.4[2-4]?.sgi" would work though, for other reasons. Haven't tried it yet.

Making movies in parts

Supply an E (note the problem with jerks every E frames.. it might be ok though to specify E = 1 and then move extra slowly!) when calling . Then when you make a mistake while recording, press escape, and notice where the last 'where' command was given when you were still happy with the recording. This would have resulted in an output to the screen of something along the lines of

camera at -5208.9302 -1778.4200 -17761.3008
looking to 0.2801 0.0956 0.9552
jump -5208.93 -1778.42 -17761.3  5.4884 -163.654 -0.146819  1
c2w: -0.959508 -0.00255072 0.281671 0  -0.0293766 0.995412 -0.0910568 0  -0.280147 -0.0956442 -0.955181 0  -5208.93 -1778.42 -17761.3 1

Grab the last line, and place it (preceded by an 'eval') at the end of the .cf file that you call with Partiview. So the last line of that file is now:

eval jump -5208.93 -1778.42 -17761.3  5.4884 -163.654 -0.146819  1

Or just type 'jump -5208.93 -1778.42 -17761.3 5.4884 -163.654 -0.146819 1' next time you start Partiview.

Important: Create a new directory, call it, say, PART4 (if this is the fourth set of images you've made for your whole animation) and move all the .sgi files created in there. There should be no .sgi files left when you restart Partiview.

Restart partiview, get to where you left off, and start recording again. The problem now is that all the snap.*.sgi files are numbered once again from 0. You'll have to rename them in future to avoid name clashes. You can do that (later) with the script.

perl K snap.*.sgi

This adds K to the numbers of each file in snap.*.sgi. You may need to run again.

K can be negative. It had better be an integer.

Note: This is best run with no other .sgi files in the directory other than those being nameshifted.

Making stereo movies

Once you can get 2d movies, getting stereo movies isn't a problem. Just place

  eval stereo -0.01 left


  eval stereo -0.01 right

The -0.01 is whatever parameter you would normally use when saying "stereo -0.01 crosseyed". We find -0.01 usually works for the stuff we're doing.

At the end of your .cf file, or type 'stereo -0.01 left' (or 'stereo -0.01 right') in in the command window before you start taking snapshots. You end up with a left-eye movie and a right-eye movie. I believe the default mono movies you get are actually left-eye movies.

Those two movies can be put together with a third party program (e.g. Director).

Dinoj Surendran, Friday, 13 February 2003, (section on 'Making stereo movies' added on 16 March 2003.)