ppmtompeg - encode an MPEG-1 bitstream |
ppmtompeg [options] parameter-file |
This program is part of Netpbm(1). ppmtompeg produces an MPEG-1 video stream. MPEG-1 is the first great video compression method, and is what is used in Video CDs (VCD). ppmtompeg originated in the year 1995. DVD uses a more advanced method, MPEG-2. There is an even newer method called MPEG-4 which is also called Divx. I don’t know where one finds that used. There’s technically a difference between a compression method for video and an actual file (stream) format for a movie, and I don’t know if it can be validly said that the format of the stream ppmtompeg produces is MPEG-1. Mencoder from the Mplayer package is probably superior for most video format generation needs, if for no other reason than that it is more popular. The programming library PM2V generates MPEG-2 streams. Use Mplayer (not part of Netpbm) to do the reverse conversion: to create a series of PNM files from an MPEG stream. param_file is a parameter file which includes a list of input files and other parameters. The file is described in detail below. To understand this program, you need to understand something about the complex MPEG-1 format. One source of information about this standard format is the section Introduction to MPEG in the Compression FAQ . |
The -gop, -combine_gops, -frames, and -combine_frames options are all mutually exclusive. |
-stat stat_file |
This option causes ppmtompeg to append the statistics that it write to Standard Output to the file stat_file as well. The statistics use the following abbreviations: bits per block (bpb), bits per frame (bpf), seconds per frame (spf), and bits per second (bps). These statistics include how many I, P, and B frames there were, and information about compression and quality. |
-quiet num_seconds |
causes ppmtompeg not to report remaining time more often than every num_seconds seconds (unless the time estimate rises, which will happen near the beginning of the run). A negative value tells ppmtompeg not to report at all. 0 is the default (reports once after each frame). Note that the time remaining is an estimate and does not take into account time to read in frames. |
-realquiet |
causes ppmtompeg to run silently, with the only screen output being errors. Particularly useful when reading input from stdin. |
-no_frame_summary |
This option prevents ppmtompeg from printing a summary line for each frame |
-float_dct |
forces ppmtompeg to use a more accurate, yet more computationally expensive version of the DCT. |
-gop gop_num |
causes ppmtompeg to encode only the numbered GOP (first GOP is 0). The parameter file is the same as for normal usage. The output file will be the normal output file with the suffix .gop.gop_num. ppmtompeg does not output any sequence information. |
-combine_gops |
causes ppmtompeg simply to combine some GOP files into a single MPEG output stream. ppmtompeg inserts a sequence header and trailer. In this case, the parameter file needs only to contain the SIZE value, an output file, and perhaps a list of input GOP files (see below). If you don’t supply a list of input GOP files is used, then ppmtompeg assumes you’re using the same parameter file you used when you created the input (with the -gop option) and calculates the corresponding gop filenames itself. If this is not the case, you can specify input GOP files in the same manner as normal input files -- except instead of using INPUT_DIR, INPUT, and END_INPUT, use GOP_INPUT_DIR, GOP_INPUT, and GOP_END_INPUT. If no input GOP files are specified, then the default is to use the output file name with suffix .gop.gop_num, with gop_num starting from 0, as the input files. Thus, unless you’re mixing and matching GOP files from different sources, you can simply use the same parameter file for creating the GOP files (-gop) and for later turning them into an MPEG stream (-combine_gops). |
-frames first_frame last_frame |
This option causes ppmtompeg to encode only the frames numbered first_frame to last_frame, inclusive. The parameter file is the same as for normal usage. The output will be placed in separate files, one per frame, with the file names being the normal output file name with the suffix .frame.frame_num. No GOP header information is output. (Thus, the parameter file need not include the GOP_SIZE value) Use ppmtompeg -combine_frames to combine these frames later into an MPEG stream. |
-combine_frames |
This option causes ppmtompeg simply to combine some individual MPEG frames (such as you might have created with an earlier run of ppmtompeg -frames) into a single MPEG stream. Sequence and GOP headers are inserted appropriately. In this case, the parameter file needs to contain only the SIZE value, the GOP_SIZE value, an output file, and perhaps a list of frame files (see below). The parameter file may specify input frame files in the same manner as normal input files -- except instead of using INPUT_DIR, INPUT, and END_INPUT, use FRAME_INPUT_DIR, FRAME_INPUT, and FRAME_END_INPUT. If no input frame files are specified, then the default is to use the output file name with suffix .frame.frame_num, with frame_num starting from 0, as the input files. |
-nice |
This option causes ppmtompeg to run any remote processes "nicely," i.e. at low priority. (This is relevant only if you are running ppmtompeg in parallel mode. Otherwise, there are no remote processes). See ’man nice.’ |
-max_machines num_machines |
This option causes ppmtompeg to use no more than num_machines machines as slaves for use in parallel encoding. |
-snr |
This option causes ppmtompeg to include the signal-to-noise ratio in the reported statistics. Prints SNR (Y U V) and peak SNR (Y U V) for each frame. In summary, prints averages of luminance only (Y). SNR is defined as 10*log(variance of original/variance of error). Peak SNR is defined as 20*log(255/RMSE). Note that ppmtompeg runs a little slower when you use this option. |
||
-mse |
This option causes ppmtompeg to report the mean squared error per block. It also automatically reports the quality of the images, so there is no need to specify -snr then. |
-bit_rate_info rate_file |
This option makes ppmtompeg write bit rate information into the file rate_file. Bit rate information is bits per frame, and also bits per I-frame-to-I-frame. |
-mv_histogram |
This option causes ppmtompeg to print a histogram of the motion vectors as part of statistics. There are three histograms -- one for P frame, one for forward B frame, and one for backward B frame motion vectors. The output is in the form of a matrix, each entry corresponding to one motion vector in the search window. The center of the matrix represents (0,0) motion vectors. |
-debug_sockets |
This option causes ppmtompeg to print to Standard Output messages that narrate the communication between the machines when you run ppmtompeg in parallel mode . |
-debug_machines |
This option causes ppmtompeg to print to Standard Output messages that narrate the progress of the conversion on the various machines when you run ppmtompeg in parallel mode . |
The parameter file must contain the following lines (except when using the -combine_gops or -combine_frames options): |
PATTERN pattern |
This statement specifies the pattern (sequence) of I frames, P frames, and B frames. pattern is just a sequence of the letters I, P, and B with nothing between. Example: PATTERN IBBPBBPBBPBBPBB See I Frames, P Frames, B Frames . |
OUTPUT output file |
This names the file where the output MPEG stream goes. |
INPUT_DIR directory |
This statement tells where the input images (frames) come from. If each frame is in a separate file, directory is the directory where they all are. You may use . to refer to the current directory. A null directory refers to the root directory of the system file tree. To have ppmtompeg read all the frames serially from Standard Input, specify INPUT_DIR stdin |
INPUT |
This line must be followed by a list of the input files (in display order) and then the line END_INPUT. |
There are three types of lines between INPUT and END_INPUT. First, a line may simply be the name of an input file. Second, the line may be of the form single_star_expr [x-y]. single_star_expr can have a single * in it. It is replaced by all the numbers between x and y inclusive. So, for example, the line tennis*.ppm [12-15] refers to the files tennis12.ppm, tennis13.ppm, tennis14.ppm, tennis15.ppm. Uniform zero-padding occurs, as well. For example, the line football.*.ppm [001-130] refers to the files football.001.ppm, football.002.ppm, ..., football.009.ppm, football.010.ppm, ..., football.130.ppm. The third type of line is: single_star_expr [x-y+s], where the line is treated exactly as above, except that we skip by s. Thus, the line football.*.ppm [001-130+4] refers to the files football.001.ppm, football.005.ppm, football.009.ppm, football.013.ppm, etc. Furthermore, a line may specify a shell command to execute to generate lines to be interpreted as described above, as if those lines were in the parameter file instead. Use back ticks, like in the Bourne Shell, like this: |
‘cat myfilelist‘ If input is from Standard Input (per the INPUT_DIR statement), ppmtompeg ignores the INPUT/END_INPUT block, but it still must be present. |
BASE_FILE_FORMAT {PPM | PNM | YUV | |
JPEG | JMOVIE} ppmtompeg must convert all input files to one of the following formats as a first step of processing: PNM, YUV, JPEG(v4), or JMOVIE. (The conversion may be trivial if your input files are already in one of these formats). This line specifies which of the four formats. PPM is actually a subset of PNM. The separate specification is allowed for backward compatibility. Use PNM instead of PPM in new applications. |
INPUT_CONVERT conversion_command |
You must specify how to convert a file to the base file format. If no conversion is necessary, then you would just say: INPUT_CONVERT * Otherwise, conversion_command is a shell command that causes an image in the format your specified with BASE_FILE_FORMAT to be written to Standard Output. ppmtompeg executes the command once for each line between INPUT and END_INPUT (which is normally, but not necessarily, a file name). In the conversion command, ppmtompeg replaces each ’*’ with the contents of that line. If you had a bunch of gif files, you might say: INPUT_CONVERT giftopnm * If you have a bunch of separate a.Y, a.U, and a.V files (where the U and V have already been subsampled), then you might say: INPUT_CONVERT cat *.Y *.U *.V Input conversion is not allowed with input from stdin, so use INPUT_CONVERT * as described above. |
SIZE widthxheight |
width and height are the width and height of each frame in pixels. When ppmtompeg can get this information from the input image files, it ignores the SIZE parameter and you may omit it. When the image files are in YUV format, the files don’t contain dimension information, so SIZE is required. When ppmtompeg is running in parallel mode, not all of the processes in the network have access to the image files, so SIZE is required and must give the same dimensions as the input image files. |
YUV_SIZE widthxheight |
This is an obsolete synonym of SIZE. |
YUV_FORMAT {ABEKAS | PHILLIPS | UCB | |
EYUV | pattern} This is meaningful only when BASE_FILE_FORMAT specifies YUV format, and then it is required. It specifies the sub-format of the YUV class. |
GOP_SIZE n |
n is the number of frames in a Group of Pictures. Except that because a GOP must start with an I frame, ppmtompeg makes a GOP as much longer than n as it has to to make the next GOP start with an I frame. Normally, it makes sense to make your GOP size a multiple of your pattern length (the latter is determined by the PATTERN parameter file statement). See Group Of Pictures . |
SLICES_PER_FRAME n |
n is roughly the number of slices per frame. Note, at least one MPEG player may complain if slices do not start at the left side of an image. To ensure this does not happen, make sure the number of rows is divisible by SLICES_PER_FRAME. |
PIXEL {FULL | HALF} |
use half-pixel motion vectors, or just full-pixel ones It is usually important that you use half-pixel motion vectors, because it results in both better quality and better compression. |
RANGE n |
Use a search range of n pixels in each of the four directions from a subject pixel. (So the search window is a square n*2 pixels on a side). |
PSEARCH_ALG {EXHAUSTIVE | TWOLEVEL | |
SUBSAMPLE | LOGARITHMIC} This statement tells ppmtompeg what kind of search technique (algorithm) to use for P frames. You select the desired combination of speed and compression. EXHAUSTIVE gives the best compression, but LOGARITHMIC is the fastest. TWOLEVEL is an exhaustive full-pixel search, followed by a local half- pixel search around the best full-pixel vector (the PIXEL option is ignored for this search technique). |
BSEARCH_ALG {SIMPLE | CROSS2 | EXHAUSTIVE} |
This statement tells ppmtompeg what kind of search technique (algorithm) to use for B frames. SIMPLE means find best forward and backward vectors, then interpolate. CROSS2 means find those two vectors, then see what backward vector best matches the best forward vector, and vice versa. EXHAUSTIVE does an n-squared search and is extremely slow in relation to the others (CROSS2 is about half as fast as SIMPLE). |
IQSCALE n |
Use n as the qscale for I frames. See Qscale . |
PQSCALE n |
Use n as the qscale for P frames. See Qscale . |
BQSCALE n |
Use n as the qscale for B frames. See Qscale . |
REFERENCE_FRAME {ORIGINAL | DECODED} |
This statement determines whether ppmtompeg uses the original images or the decoded images when computing motion vectors. Using decoded images is more accurate and should increase the playback quality of the output, but it makes the encoding take longer and seems to give worse compression. It also causes some complications with parallel encoding. (see the section on parallel encoding). One thing you can do as a trade-off is select ORIGINAL here, and lower the qscale (see QSCALE if the quality is not good enough. Original or Decoded? (Normalized) |
|
|
|
|
PARALLEL OPERATION
SPEED
AUTHORS
|