Dytran > Read Results > Assembling an Animation from Separate Frames
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Assembling an Animation from Separate Frames
If an animation is built from separate frames, the frames must have all the same size. The files must also be of the same type. If they are not, the program dytranp3, described in the next section, may provide a solution. If the files of the separate frames are used as input for the dytranp3 to create an MPEG file, the numbering of the files will define the order in which the frames are processed. In some cases the numbering of the files may not be as desired. In such situation a simple shell script can help to renumber a large number of files.
DYTRANP3 Functions for Window Grabbing and MPEG Generation
DYTRANP3 is primarily the interface between Dytran and Patran. In addition it is the home of several utilities needed for the conversion of series of Patran generated image files into MPEG animations. Which utility is used depends on the first argument:
-grab
grab a window from the display and convert it into .ppm or .YUV format.
-ppm2yuv
convert a ppm file into a set of YUV files
-img2ppm
convert an .img file into .ppm format
-img2yuv
convert an .img file into YUV format
-ppm2mpg
create an MPEG animation from a series of .ppm files
-yuv2mpg
create an MPEG animation from a series of .yuv files
-img2mpg
create an MPEG animation from a series of .img files
The creation of an MPEG animation requires the executable of the “MPEG-codec” to be present in:
Any directory included in your “search path”
A directory specified by the environment variable MPEGDIR
The directory $DYTRANDIR/patran, with DYTRANDIR an environment variable used to specify the root of the Dytran installation directory.
GRAB
The grab utility is used to grab the contents of an X11 window and write it out in .YUV or ppm format. Outside Patran it can be started with the command
dytranp3 -grab -id <window name> -o <outfile>
[-compr|-gzip] [-ppm] [-YUV] [-noborder] [-half]
With the arguments:
 
-grab
keyword used by dytranp3 to select this routine.
-id <window name>
specifies the name of the window to be dumped
-o <outfile>
specifies the name of the output file
-ppm
keyword to force output to be in “Portable PixMap” format.
-YUV
keyword to force output in “YUV” format (three separate files).
-noborder
strips 6 pixels from each border to get rid of the red border Patran generates around the current viewport.
-half
forces all frames to be halved on both directions for higher performance when using the MPEG-player.
-compr
forces output to be compressed by standard “compress”
-gzip
forces output to be compressed by GNU gzip
Using the “-compr” or “-gzip” option will save a lot of disk space. Since the ppm2mpg option will automatically detect compressed files, there is no need to uncompress .ppm files before they are used to create an MPEG file. The -half option is useful since typical output windows are of the order of magnitude of 640 x 480, while the size used for MPEG’s is usually in the order of 320 x 240. In theory MPEG-player can handle any size but large frames will decrease the performance of the player.
PPM2YUV
The -ppm2yuv utility is used to convert one single ppm file into a set of YUV files (the YUV format uses three separate files for one image).
Outside Patran it can be started with:
dytranp3 -ppm2yuv file.ppm [-half]
with
 
file.ppm
the name of the ppm file to be converted into YUV format
-half
forces all frames to be halved on both directions for a better performance when using the MPEG-player.
Remarks:
Compressed files (with .Z or .gz) will be recognized, and decompressed automatically during read.
The extension .ppm will be replaced by the appropriate .Y, .U and .V extensions for the result files, provided no “postfix sequence” was applied. For example, example.10.ppm will result into example.10.Y etc., but example.ppm.10 will result into example.ppm.10.Y.
IMG2PPM
The -img2ppm utility is used to convert a single img file into ppm format.
Usage:
dytranp3 -img2ppm file.img [-half] [-compr | -gzip]
With arguments
 
file.img
file name of the existing .img file. Compressed files with .Z or .gz extensions will be recognized and decompressed during read. The current version does not recognize postfix sequence numbers. In that case “img” will not be stripped and “.ppm” will be appended to the full name.
-half
forces all frames to be halved in both directions for a better performance when using the MPEG-player.
-compr
forces the output ppm file to be compressed (only if the Unix compress program is in your search path).
-gzip
forces the output ppm file to be compressed by GNU zip, provided the executable is in your search path.
IMG2YUV
The -img2yuv utility is used to convert a single img file into a set of YUV files.
Usage:
dytranp3 -img2yuv file.yuv [-half] [-compr | -gzip]
With arguments
 
file.img
file name of the existing .img file. Compressed files with .Z or .gz extensions will be recognized and decompressed during read. The current version does not recognize postfix sequence numbers. In that case “img” will not be stripped and the “.Y”, “.U” and “.V” will be appended to the full name.
-half
forces all frames to be halved in both directions for better performance when using the MPEG-player.
-compr
forces the output YUV files to be compressed (only if the Unix compress program is in your search path).
-gzip
forces the output YUV file to be compressed by GNU gzip, provided the executable is in your search path.
Remarks:
The MPEG codec does not support reading of compressed files, so when the compress options are used, the files should be decompressed before “yuv2mpg” is started.
Don’t forget to make a note about the actual size of the frames (height and width in pixels), because the dimensions are not stored on the YUV files and have to be passed to “yuv2mpeg”
by arguments.
PPM2MPG
Create an MPEG animation from a series of .ppm files.
Usage:
dytranp3 -ppm2mpg prefix ifirst ilast [-half] [-pad <N>] [-postnum]
With arguments
 
prefix
prefix of the files to be converted. The program dytranp3 expects the files to be present as: prefix.N.ppm or prefix.ppm.N (when “-postnum” was selected). with N being a sequence number in the range ifirst <= N <= ilast. Also compressed files with .Z and .gz extensions will be recognized and decompressed automatically, provided the compress or gzip executables are present in the users search path.
ifirst
sequence number of the first frame to be used.
ilast
sequence number of the last frame to be used.
-half
forces all frames to be halved in both directions for a better performance when using the MPEG-player.
-pad <N>
pad sequence numbers with leading zeros up to N digits. For example “-pad 3” will expect file names like example.007.ppm.
-postnum
Sequence numbers are expected to be appended to the file names: example.ppm.007 (if also “pad -3” was used)
The program will create a subdirectory named prefix_PID, with <PID> the process id of the current process used to force a unique name. In this directory it will create the YUV files needed by the
“MPEG codec.” The “MPEG codec” is executed in a child process. When finished, the resulting MPEG file is moved to the directory from which the program was started and the “prefix_PID” scratch directory is removed.
IMG2MPG
Create an MPEG animation from a series of .img files.
Usage:
dytranp3 -img2mpg prefix ifirst ilast [-half] [-pad <N>] [-postnum]
With arguments
 
prefix
prefix of the files to be converted. The program dytranp3 expects the files to be present as: prefix.N.img or prefix.img.N (when “-postnum” was selected). with N being a sequence number in the range ifirst <= N <= ilast. Also compressed files with .Z and .gz extensions will be recognized and decompressed automatically, provided the compress or gzip executables are present in the users search path.
ifirst
sequence number of the first frame to be used.
ilast
sequence number of the last frame to be used.
-half
forces all frames to be halved on both directions for a better performance when using the MPEG-player.
-pad <N>
pad sequence numbers with leading zeros up to N digits. For example “-pad 3” will expect file names like example.007.img.
-postnum
Sequence numbers are expected to be appended to the file names: example.img.007 (if also “pad -3” was used)
The program will create a subdirectory named prefix_PID, with <PID> the process id of the current process, to force a unique name. In this directory it will create the YUV files needed by the “MPEG codec.” The “MPEG codec” is executed in a child process, and when finished, the resulting MPEG file is moved to the directory from which the program was started and the “prefix_PID” scratch directory is removed.
YUV2MPG
Create an MPEG animation from a series of .yuv files
Usage:
dytranp3 -yuv2mpg prefix ifirst ilast hsize vsize [-pad <N>] [-postnum]
With arguments
 
prefix
prefix of the files to be converted. The program dytranp3 expects the files to be present as: prefix.N.[YUV] or prefix.[YUV].N (when “-postnum” was selected) with N being a sequence number in the range ifirst <= N <= ilast. Note that compressed files (.gz and .Z ) cannot be handled here.
hsize
the horizontal size of the frames in pixels
vsize
the vertical size of the frames in pixels
-pad <N>
pad sequence numbers with leading zeros up to N digits.
For example “-pad 3” will expect file names like example.007.Y
-postnum
Sequence numbers are expected to be appended to the file names: example.Y.007 (if also “pad -3” was used)