The basic ideas are more generally useful: a program can take snapshots of itself, for example, using basically the same steps.
The idea is to run a script, giving commands to the tcl program, and then taking a snapshot. Start the tcl program in background, for example,
~sethna/run_Jupiter ^Z bgand set up the parameters until just before the first frame (i.e., set masses and time intervals).
Then start up wish. For the time being, version 4.0 is available via a shell script:
~sethna/run_wishWish can be used to try out tcl commands. We're using it in a different way: to send commands to other tcl programs! (This doesn't work on some systems, depending on how the x-authority is worked out... It works in ruph, though.)
Wish acts like a tcl interpreter, which is very much like shell scripts. (That is, some of this can also be done without tcl, so what you're learning is more general than it sounds.) Type in the following commands:
set xmin 2 set ymin 46 set width 441 set height 217 set window_name Jupiter set max_frames 5modified suitably for your movie. (An easy way to find the size of the clipped region is to grab one frame using xwd, load it into xv, clip it, and then use the Image Info window to find out what you've clipped out.) After setting up the shell-script xwd_it (see below), the following command will loop over frames, clip them, convert them to gif files, and store them as movie.XXX.gif in the current directory:
for {set frame 0} {$frame < $max_frames} {incr frame} {
send Jupiter {.run invoke}
if {$frame < 10} {
xwd_it 00$frame $window_name $xmin $ymin $width $height
} elseif {$frame < 100} {
xwd_it 0$frame $window_name $xmin $ymin $width $height
} else {
xwd_it $frame $window_name $xmin $ymin $width $height
}
}
The guts of this is done by the shell-script xwd_it.
#!/bin/csh xwd -name $2 | xwdtopnm | pnmcut $3 $4 $5 $6 | ppmtogif > movie.$1.gif exit 0If tcl was a better shell, we could have just typed the line in: but tcl seems to interpret the vertical bars | as instructions to pipe both stdout and stderr into the following stdin... Anyhow, this makes the file movie.$frame.gif from whatever window is named $window_name. It does an x-window-dump, converts it into a pnm file, cuts out a rectangle starting at (xmin, ymin) pixels from the upper left of (width, height), and then stores it as a gif file. It should be easy to modify this for your own purposes...
Finally, you'll want to encode the frames into a movie. Copy this file
# parameter file with good default values # # use this as a guideline for any parameters you don't really understand # or don't care about # PATTERN IBBPBBPBBPBBPBB OUTPUT output.mpg BASE_FILE_FORMAT PNM GOP_SIZE 30 SLICES_PER_FRAME 1 PIXEL HALF RANGE 10 PSEARCH_ALG LOGARITHMIC BSEARCH_ALG CROSS2 IQSCALE 8 PQSCALE 10 BQSCALE 25 REFERENCE_FRAME ORIGINAL # # you really need to understand the following # YUV_SIZE 352x240 INPUT_CONVERT giftopnm * INPUT_DIR . INPUT movie.*.gif [000-005] END_INPUTas gif2mpg.param, and modify it to your taste. (In particular, you're likely to have more frames than five!) YUV size is not important, since we're using PNM as the file format. Then, type
~scarlet/bin/mpeg_encode gif2mpg.paramwait, and
mpeg_play output.mpg
James P. Sethna,
sethna@lassp.cornell.edu.
Statistical Mechanics: Entropy, Order Parameters, and Complexity,
now available at
Oxford University Press
(USA,
Europe).
Statistical Mechanics: Entropy, Order Parameters, and Complexity,
now available at
Oxford University Press
(USA,
Europe).