.TL
Ppmtompeg User Manual
.SH 1
Ppmtompeg
.LP
Updated: 23 July 2006
.br
Table Of Contents
.SH 2
NAME
.LP
ppmtompeg - encode an MPEG-1 bitstream
.SH 2
SYNOPSIS
.LP
\fBppmtompeg\fR
[\fIoptions\fR]
\fIparameter-file\fR
.SH 2
DESCRIPTION
.LP
.LP
This program is part of Netpbm.
.LP
\fBppmtompeg\fR produces an MPEG-1 video stream. MPEG-1 is the
first great video compression method, and is what is used in Video CDs
(VCD). \fBppmtompeg\fR 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.
.LP
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
\fBppmtompeg\fR produces is MPEG-1.
.LP
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.
.LP
The programming library \fBPM2V\fR
generates MPEG-2 streams.
.LP
Use Mplayer (not part of Netpbm)
to do the reverse conversion: to create a series of PNM files from an MPEG
stream.
.LP
\fIparam_file\fR is a parameter file which includes a list of
input files and other parameters. The file is described in detail
below.
.LP
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 theCompression FAQ.
.SH 2
OPTIONS
.LP
.LP
The \fB-gop\fR, \fB-combine_gops\fR, \fB-frames\fR, and
\fB-combine_frames\fR options are all exclusive.
.RS
.IP "\fB-stat stat_file\fR"
This option causes \fBppmtompeg\fR to append the statistics that
it write to Standard Output to the file \fIstat_file\fR 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).
.LP
These statistics include how many I, P, and B frames there were,
and information about compression and quality.
.IP "\fB-quiet\fR \fInum_seconds\fR"
causes \fBppmtompeg\fR not to report remaining time more often
than every \fInum_seconds\fR seconds (unless the time estimate rises,
which will happen near the beginning of the run). A negative value
tells \fBppmtompeg\fR 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.
.IP "\fB-realquiet\fR causes \fBppmtompeg\fR to run silently,"
with the only screen output being errors. Particularly useful when
reading input from stdin.
.IP ""\fB-no_frame_summary\fR
This option prevents \fBppmtompeg\fR from printing a summary
line for each frame
.IP "\fB-float_dct\fR"
forces \fBppmtompeg\fR to use a more accurate, yet more
computationally expensive version of the DCT.
.IP "\fB-gop\fR \fIgop_num\fR"
causes \fBppmtompeg\fR 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 \fB.gop.\fR\fIgop_num\fR.
\fBppmtompeg\fR does not output any sequence information.
.IP "\fB-combine_gops\fR"
causes \fBppmtompeg\fR simply to combine some GOP files into a
single MPEG output stream. \fBppmtompeg\fR 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
\fBppmtompeg\fR assumes you're using the same parameter file you used
when you created the input (with the \fB-gop\fR 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 \fB.gop.\fR\fIgop_num\fR, with \fIgop_num\fR
starting from 0, as the input files.
.LP
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 (\fB-gop\fR) and for later turning them into an MPEG stream
(\fB-combine_gops\fR).
.IP "\fB-frames \fIfirst_frame\fB \fIlast_frame\fB\fR"
This option causes \fBppmtompeg\fR to encode only the frames numbered
\fIfirst_frame\fR to \fIlast_frame\fR, 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 \fB.frame.\fR\fIframe_num\fR. No
GOP header information is output. (Thus, the parameter file need not
include the GOP_SIZE value)
.LP
Use \fBppmtompeg -combine_frames\fR to combine these frames later into
an MPEG stream.
.IP "\fB-combine_frames\fR"
This option causes \fBppmtompeg\fR simply to combine some
individual MPEG frames (such as you might have created with an earlier
run of \fBppmtompeg -frames\fR) 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).
.LP
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 \fB.frame.\fR\fIframe_num\fR, with
\fIframe_num\fR starting from 0, as the input files.
.IP "\fB-nice\fR"
This option causes \fBppmtompeg\fR to run any remote processes
"nicely," i.e. at low priority. (This is relevant only if you are
running \fBppmtompeg\fR in parallel mode. Otherwise, there are no
remote processes). See 'man nice.'
.IP "\fB-max_machines \fInum_machines\fB\fR"
This option causes \fBppmtompeg\fR to use no more than
\fInum_machines\fR machines as slaves for use in parallel encoding.
.IP "\fB-snr\fR "
This option causes \fBppmtompeg\fR 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
\fBppmtompeg\fR runs a little slower when you use this option.
.IP "\fB-mse\fR"
This option causes \fBppmtompeg\fR to report the mean squared
error per block. It also automatically reports the quality of the
images, so there is no need to specify \fB-snr\fR then.
.IP "\fB-bit_rate_info\fR \fIrate_file\fR"
This option makes \fBppmtompeg\fR write bit rate information
into the file \fIrate_file\fR. Bit rate information is bits per frame, and
also bits per I-frame-to-I-frame.
.IP "\fB-mv_histogram\fR "
This option causes \fBppmtompeg\fR 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.
.LP
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.
.IP "\fB-debug_sockets\fR"
This option causes \fBppmtompeg\fR to print to Standard Output
messages that narrate the communication between the machines when you run
\fBppmtompeg\fR in parallel mode.
.IP "\fB-debug_machines\fR"
This option causes \fBppmtompeg\fR to print to Standard Output
messages that narrate the progress of the conversion on the various
machines when you run \fBppmtompeg\fR in parallel
mode.
.RE
.SH 2
PARAMETER FILE
.LP
.LP
The parameter file must contain the following
lines (except when using the \fB-combine_gops\fR or \fB-combine_frames\fR
options):
.RS
.IP "\fBPATTERN\fR \fIpattern\fR"
This statement specifies the pattern (sequence) of I frames, P frames,
and B frames. \fIpattern\fR is just a sequence of the letters I, P, and
B with nothing between. Example:
.DS L
PATTERN IBBPBBPBBPBBPBB
.DE
.LP
See I Frames, P Frames, B Frames.
.IP "\fBOUTPUT\fR \fIoutput file\fR"
This names the file where the output MPEG stream goes.
.IP "\fBINPUT_DIR\fR \fIdirectory\fR"
This statement tells where the input images (frames) come from.
If each frame is in a separate file, \fIdirectory\fR is the directory
where they all are. You may use \fB.\fR to refer to the current
directory. A null \fIdirectory\fR refers to the root directory of the
system file tree.
.LP
To have \fBppmtompeg\fR read all the frames serially from Standard
Input, specify
.DS L
INPUT_DIR stdin
.DE
.IP "\fBINPUT\fR"
This line must be followed by a list of the input files (in display order)
and then the line \fBEND_INPUT\fR.
.LP
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 \fIsingle_star_expr\fR
\fB[\fR\fIx\fR\fB-\fR\fIy\fR\fB]\fR.
\fIsingle_star_expr\fR can have a single \fB*\fR in it. It is
replaced by all the numbers between x and y inclusive. So, for
example, the line \fBtennis*.ppm [12-15]\fR refers to the files
tennis12.ppm, tennis13.ppm, tennis14.ppm, tennis15.ppm.
.LP
Uniform zero-padding occurs, as well. For example, the line
\fBfootball.*.ppm [001-130]\fR refers to the files football.001.ppm,
football.002.ppm, ..., football.009.ppm, football.010.ppm, ...,
football.130.ppm.
.LP
The third type of line is: \fIsingle_star_expr\fR
\fB[\fR\fIx\fR\fB-\fR\fIy\fR\fB+\fR\fIs\fR\fB]\fR, where the
line is treated exactly as above, except that we skip by \fIs\fR. Thus, the
line \fBfootball.*.ppm [001-130+4]\fR refers to the files
football.001.ppm, football.005.ppm, football.009.ppm,
football.013.ppm, etc.
.LP
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:
.DS L
`cat myfilelist`
.DE
.LP
If input is from Standard Input (per the \fBINPUT_DIR\fR statement),
\fBppmtompeg\fR ignores the \fBINPUT\fR/\fBEND_INPUT\fR block, but
it still must be present.
.IP "\fBBASE_FILE_FORMAT\fR {\fBPPM\fR | \fBPNM\fR | \fBYUV\fR | "
\fBJPEG\fR | \fBJMOVIE\fR}
\fBppmtompeg\fR 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.
.IP "\fBINPUT_CONVERT\fR \fIconversion_command\fR"
You must specify how to convert a file to the base file format.
If no conversion is necessary, then you would just say:
.DS L
INPUT_CONVERT *
.DE
.LP
Otherwise, \fIconversion_command\fR is a shell command that causes
an image in the format your specified with \fBBASE_FILE_FORMAT\fR to
be written to Standard Output. \fBppmtompeg\fR executes the command
once for each line between \fBINPUT\fR and \fBEND_INPUT\fR (which is
normally, but not necessarily, a file name). In the conversion
command, \fBppmtompeg\fR replaces each '*' with the contents of that
line.
If you had a bunch of gif files, you might say:
.DS L
INPUT_CONVERT giftopnm *
.DE
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:
.DS L
INPUT_CONVERT cat *.Y *.U *.V
.DE
.LP
Input conversion is not allowed with input from stdin, so use
.DS L
INPUT_CONVERT *
.DE
as described above.
.IP "\fBSIZE\fR \fIwidth\fR\fBx\fR\fIheight\fR"
.LP
\fIwidth\fR and \fIheight\fR are the width and height of each
frame in pixels.
.LP
When \fBppmtompeg\fR can get this information from the input image
files, it ignores the \fBSIZE\fR parameter and you may omit it.
.LP
When the image files are in YUV format, the files don't contain
dimension information, so \fBSIZE\fR is required.
.LP
When \fBppmtompeg\fR is running in parallel mode, not all of the
processes in the network have access to the image files, so
\fBSIZE\fR is required and must give the same dimensions as the
input image files.
.IP "\fBYUV_SIZE\fR \fIwidth\fR\fBx\fR\fIheight\fR"
This is an obsolete synonym of \fBSIZE\fR.
.IP "\fBYUV_FORMAT\fR {\fBABEKAS\fR | \fBPHILLIPS\fR | \fBUCB\fR |"
\fBEYUV\fR | \fIpattern\fR}
This is meaningful only when \fBBASE_FILE_FORMAT\fR specifies
YUV format, and then it is required. It specifies the sub-format of
the YUV class.
.IP "\fBGOP_SIZE\fR \fIn\fR"
\fIn\fR is the number of frames in a Group of Pictures. Except that
because a GOP must start with an I frame, \fBppmtompeg\fR makes a GOP as
much longer than \fIn\fR as it has to to make the next GOP start with an
I frame.
.LP
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).
.LP
See Group Of Pictures.
.IP "\fBSLICES_PER_FRAME\fR \fIn\fR"
\fIn\fR 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.
.IP "\fBPIXEL\fR {\fBFULL\fR | \fBHALF\fR} "
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.
.IP "\fBRANGE\fR \fIn\fR"
Use a search range of \fIn\fR pixels in each of the four directions
from a subject pixel. (So the search window is a square \fIn\fR*2 pixels
on a side).
.IP "\fBPSEARCH_ALG\fR {\fBEXHAUSTIVE\fR | \fBTWOLEVEL\fR |"
\fBSUBSAMPLE\fR | \fBLOGARITHMIC\fR}
This statement tells \fBppmtompeg\fR what kind of search
technique (algorithm) to use for P frames. You select the desired
combination of speed and compression. \fBEXHAUSTIVE\fR gives the
best compression, but \fBLOGARITHMIC\fR is the fastest.
\fBTWOLEVEL\fR 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).
.IP "\fBBSEARCH_ALG\fR {\fBSIMPLE\fR | \fBCROSS2\fR | \fBEXHAUSTIVE\fR}"
This statement tells \fBppmtompeg\fR what kind of search
technique (algorithm) to use for B frames. \fBSIMPLE\fR means
find best forward and backward vectors, then interpolate.
\fBCROSS2\fR means find those two vectors, then see what backward
vector best matches the best forward vector, and vice versa.
\fBEXHAUSTIVE\fR does an n-squared search and is
extremely slow in relation to the others (\fBCROSS2\fR
is about half as fast as \fBSIMPLE\fR).
.IP "\fBIQSCALE\fR \fIn\fR"
Use \fIn\fR as the qscale for I frames.
See Qscale.
.IP "\fBPQSCALE\fR \fIn\fR"
Use \fIn\fR as the qscale for P frames.
See Qscale.
.IP "\fBBQSCALE\fR \fIn\fR"
Use \fIn\fR as the qscale for B frames.
See Qscale.
.IP "\fBREFERENCE_FRAME\fR {\fBORIGINAL\fR | \fBDECODED\fR} This"
statement determines whether \fBppmtompeg\fR 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 \fBORIGINAL\fR here, and lower the
qscale (see \fBQSCALE\fR if the quality is not good enough.
.TS
center ;
Original or Decoded? (Normalized)
<?makeman r c c c c c. ?>
<?makeman _ ?>
<tr align="center" bgcolor="#CCCCCC">
<th>
Reference</th>
<th>
Compression</th>
<th>
Speed</th>
<th>
Quality I</th>
<th>
Quality P</th>
<th>
Quality B</th>
</tr>
<tr>
<td align="right">
Decoded</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
<td align="center">
969</td>
<td align="center">
919</td>
</tr>
<tr>
<td align="right">
Original</td>
<td align="center">
885</td>
<td align="center">
1373</td>
<td align="center">
1000</td>
<td align="center">
912</td>
<td align="center">
884</td>
</tr>
.TE
.RE
.LP
The following lines are optional:
.RS
.IP "\fBFORCE_ENCODE_LAST_FRAME\fR"
This statement is obsolete. It does nothing.
.LP
Before Netpbm 10.26 (January 2005), \fBppmtompeg\fR would drop
trailing B frames from your movie, since a movie can't end with a B
frame. (See I Frames, P Frames, B Frames.
You would have to specify \fBFORCE_ENCODE_LAST_FRAME\fR to stop
that from happening and get the same function that \fBppmtompeg\fR
has today.
.IP "\fBNIQTABLE\fR"
This statement specifies a custom non-intra quantization table.
If you don't specify this statement, \fBppmtompeg\fR uses a default
non-intra quantization table.
.LP
The 8 lines immediately following \fBNIQTABLE\fR specify the quantization
table. Each line defines a table row and consists of 8 integers,
whitespace-delimited, which define the table columns.
.IP "\fBIQTABLE\fR"
This is analogous to NIQTABLE, but for the intra quantization table.
.IP "\fBASPECT_RATIO\fR \fIratio\fR"
This statement specifies the aspect ratio for \fBppmtompeg\fR to
specify in the MPEG output. I'm not sure what this is used for.
.LP
\fIratio\fR must be 1.0, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437,
0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, or 1.2015.
.IP "\fBFRAME_RATE\fR \fIrate\fR"
This specifies the frame rate for \fBppmtompeg\fR to specify in the
MPEG output. Some players use this value to determine the playback rate.
.LP
\fIrate\fR must be 23.976, 24, 25, 29.97, 30, 50, 59.94, or 60.
.IP "\fBBIT_RATE\fR \fIrate\fR"
This specifies the bit rate for Constant Bit Rate (CBR) encoding.
.LP
\fIrate\fR must be an integer.
.IP "\fBBUFFER_SIZE\fR \fIsize\fR "
This specifies the value
\fBppmtompeg\fR is to specify in the MPEG output for the Video
Buffering Verifier (VBV) buffer size needed to decode the sequence.
.LP
A Video Verifying Buffer is a buffer in which a decoder keeps the
decoded bits in order to match the uneven speed of the decoding with
the required constant playback speed.
.LP
As \fBppmtompeg\fR encodes the image, it simulates the decoding
process in terms of how many bits would be in the VBV as each frame gets
decoded, assuming a VBV of the size you indicate.
.LP
If you specify the \fBWARN_VBV_UNDERFLOW\fR statement,
\fBppmtompeg\fR issues a warning each time the simulation underflows
the buffer, which suggests that an underflow would occur on playback,
which suggests the buffer is too small.
.LP
If you specify the \fBWARN_VBV_OVERFLOW\fR statement,
\fBppmtompeg\fR issues a warning each time the simulation overflows
the buffer, which suggests that an overflow would occur on playback,
which suggests the buffer is too small.
.IP "\fBWARN_VBV_UNDERFLOW\fR"
.IP "\fBWARN_VBV_OVERFLOW\fR"
See \fBBUFFER_SIZE\fR.
.LP
These options were new in Netpbm 10.26 (January 2005). Before that,
\fBppmtompeg\fR issued the warnings always.
.RE
The following statements apply only to parallel operation:
.RS
.IP "\fBPARALLEL\fR"
This statement, paired with \fBEND PARALLEL\fR, is what causes
\fBppmtompeg\fR to operate in parallel mode. See Parallel Operation.
.IP "\fBEND PARALLEL\fR"
This goes with \fBPARALLEL\fR.
.IP "\fBPARALLEL_TEST_FRAMES\fR \fIn\fR "
The master starts off by measuring each slave's speed. It does
this by giving each slave \fIn\fR frames to encode and noting how
long the slave takes to finish. These are not just test frames,
though -- they're real frames and the results become part of the
output.
\fBppmtompeg\fR is old and measures time in undivided seconds, so
to get useful timings, specify enough frames that it will take at
least 5 seconds to process them. The default is 10.
.LP
If you specify \fBFORCE_I_ALIGN\fR, \fBppmtompeg\fR will increase
the test frames value enough to maintain the alignment.
.LP
If there aren't enough frames for every slave to have the indicated
number of test frames, \fBppmtompeg\fR will give some slaves fewer.
.IP "\fBPARALLEL_TIME_CHUNKS\fR \fIt\fR"
When you specify this statement, the master attempts to feed work
to the slaves in chunks that take \fIt\fR seconds to process. It uses
the speed measurement it made when it started up (see PARALLEL_TEST_FRAMES)
to decide how many frames to put in the chunk. This statement obviously
doesn't affect the first batch of work sent to each slave, which is the
one used to measure the slave's speed.
.LP
Smaller values of \fIt\fR increase communication, but improve load
balancing. The default is 30 seconds.
.LP
You may specify only one of PARALLEL_TIME_CHUNKS, PARALLEL_CHUNK_TAPER,
and PARALLEL_PERFECT. PARALLEL_CHUNK_TAPER is usually best.
.IP "\fBPARALLEL_CHUNK_TAPER\fR"
When you specify this statement, the master distributes work like
with PARALLEL_TIME_CHUNKS, except that the master chooses the number
of seconds for the chunks. It starts with a large number and, as it
gets closer to finishing the job, reduces it. That way, it reduces
scheduling overhead when precise scheduling isn't helpful, but still
prevents a slave from finishing early after all the work has already
been handed out to the other slaves, and then sitting idle while
there's still work to do.
.LP
You may specify only one of PARALLEL_TIME_CHUNKS, PARALLEL_CHUNK_TAPER,
and PARALLEL_PERFECT. PARALLEL_CHUNK_TAPER is usually best.
.IP "\fBPARALLEL_PERFECT\fR"
If this statement is present, \fBppmtompeg\fR schedules on the
assumption that each machine is about the same speed. The master will
simply divide up the frames evenly between the slaves -- each
slave gets the same number of frames. If some slaves are faster than
others, they will finish first and remain idle while the slower slaves
continue.
.LP
This has the advantage of minimal scheduling overhead. Where slaves
have different speeds, though, it makes inefficient use of the fast
ones. Where slaves are the same speed, it also has the disadvantage
that they all finish at the same time and feed their output to the
single Combine Server in a burst, which makes less efficient use of
the Combine Server and thus can increase the total elapsed time.
.LP
You may specify only one of PARALLEL_TIME_CHUNKS, PARALLEL_CHUNK_TAPER,
and PARALLEL_PERFECT. PARALLEL_CHUNK_TAPER is usually best.
.IP "\fBRSH\fR \fIremote_shell_command\fR"
\fBppmtompeg\fR executes the shell command
\fIremote_shell_command\fR to start a process on another machine.
The default command is \fBrsh\fR, and whatever command you specify
must have compatible semantics. \fBssh\fR is usually compatible.
The command \fBppmtompeg\fR uses is one like this:
\fBssh remote.host.com -l username shellcommand\fR.
.LP
Be sure to set up \fB.rhosts\fR files or SSH key authorizations
where needed. Otherwise, you'll have to type in passwords.
.LP
On some HP machines, \fBrsh\fR is the restricted shell, and you want
to specify \fBremsh\fR.
.IP "\fBFORCE_I_ALIGN\fR"
This statement forces each slave to encode a chunk of frames which
is a multiple of the pattern length (see \fBPATTERN\fR). Since the
first frame in any pattern is an I frame, this forces each chunk
encoded by a slave to begin with an I frame.
.LP
This document used to say there was an argument to
\fBFORCE_I_ALIGN\fR which was the number of frames \fBppmtompeg\fR
would use (and was required to be a multiple of the pattern length).
But \fBppmtompeg\fR has apparently always ignored that argument, and
it does now.
.IP "\fBKEEP_TEMP_FILES\fR"
This statement causes \fBppmtompeg\fR not to delete the temporary
files it uses to transmit encoded frames to the combine server. This
means you will be left with a file for each frame, the same as you
would get with the \fB-frames\fR option.
.LP
This is mostly useful for debugging.
.LP
This works only if you're using a shared filesystem to communicate
between the servers.
.LP
This option was new in Netpbm 10.26 (January 2005).
.RE
.SH 3
Parameter File Notes
.LP
.LP
If you use the \fB-combine_gops\fR option, then you need to specify
only the SIZE and OUTPUT values in the parameter file. In
addition, the parameter file may 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 you specify no input GOP files, then \fBppmtompeg\fR uses by default the
output file name with suffix \fB.gop.\fR\fIgop_num\fR, with \fIgop_num\fR
starting from 0, as the input files.
.LP
If you use the \fB-combine_frames\fR option, then you need to
specify only the SIZE, GOP_SIZE, and OUTPUT values in the
parameter file. In addition, 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
\fB.frame.\fR\fIframe_num\fR, with \fIframe_num\fR starting from 0,
as the input files.
.LP
Any number of spaces and tabs may come between each option and value. Lines
beginning with \fB#\fR are ignored. Any other lines are ignored except for
those between INPUT and END_INPUT. This allows you to use the same
parameter file for normal usage and for \fB-combine_gops\fR and
\fB-combine_frames\fR.
.LP
The file format is case-sensitive so all keywords should be in
upper case.
.LP
The statements may appear in any order, except that the order within
a block statement (such as INPUT ... END INPUT) is significant.
.LP
\fBppmtompeg\fR is prepared to handle up to 16 B frames between
reference frames when encoding with input from stdin. (To build a
modified \fBppmtompeg\fR with a higher limit, change the constant
B_FRAME_RUN in frame.c and recompile).
.SH 2
GENERAL USAGE INFORMATION
.LP
.SH 3
Qscale
.LP
.LP
The quantization scale values (qscale) give a trade-off between
quality and compression. Using different Qscale values has very little
effect on speed. The qscale values can be set separately for I, P, and
B frames.
.LP
You select the qscale values with the \fBIQSCALE\fR,
\fBPQSCALE\fR, and \fBBSCALE\fR parameter file statements.
.LP
A qscale value is an integer from 1 to 31. Larger numbers give
better compression, but worse quality. In the following, the quality
numbers are peak signal-to-noise ratio, defined as:
where MSE is the mean squared error.
.LP
Flower garden tests:
.TS
center ;
Qscale vs Quality
<?makeman r r r r. ?>
<?makeman _ ?>
<tr align="center">
<th>
Qscale</th>
<th>
I Frames</th>
<th>
P Frames</th>
<th>
B Frames</th>
</tr>
<tr>
<td align="right">
1</td>
<td align="right">
43.2</td>
<td align="right">
46.3</td>
<td align="right">
46.5</td>
</tr>
<tr>
<td align="right">
6</td>
<td align="right">
32.6</td>
<td align="right">
34.6</td>
<td align="right">
34.3</td>
</tr>
<tr>
<td align="right">
11</td>
<td align="right">
28.6</td>
<td align="right">
29.5</td>
<td align="right">
30.0</td>
</tr>
<tr>
<td align="right">
16</td>
<td align="right">
26.3</td>
<td align="right">
26.8</td>
<td align="right">
28.6</td>
</tr>
<tr>
<td align="right">
21</td>
<td align="right">
24.7</td>
<td align="right">
25.0</td>
<td align="right">
27.9</td>
</tr>
<tr>
<td align="right">
26</td>
<td align="right">
23.5</td>
<td align="right">
23.9</td>
<td align="right">
27.5</td>
</tr>
<tr>
<td align="right">
31</td>
<td align="right">
22.6</td>
<td align="right">
23.0</td>
<td align="right">
27.3</td>
</tr>
.TE
.TS
center ;
Qscale vs Compression
<?makeman r r r r. ?>
<?makeman _ ?>
<tr align="center">
<th>
Qscale</th>
<th>
I Frames</th>
<th>
P Frames</th>
<th>
B Frames</th>
</tr>
<tr>
<td align="right">
1</td>
<td align="right">
2</td>
<td align="right">
2</td>
<td align="right">
2</td>
</tr>
<tr>
<td align="right">
6</td>
<td align="right">
7</td>
<td align="right">
10</td>
<td align="right">
15</td>
</tr>
<tr>
<td align="right">
11</td>
<td align="right">
11</td>
<td align="right">
18</td>
<td align="right">
43</td>
</tr>
<tr>
<td align="right">
16</td>
<td align="right">
15</td>
<td align="right">
29</td>
<td align="right">
97</td>
</tr>
<tr>
<td align="right">
21</td>
<td align="right">
19</td>
<td align="right">
41</td>
<td align="right">
173</td>
</tr>
<tr>
<td align="right">
26</td>
<td align="right">
24</td>
<td align="right">
56</td>
<td align="right">
256</td>
</tr>
<tr>
<td align="right">
31</td>
<td align="right">
28</td>
<td align="right">
73</td>
<td align="right">
330</td>
</tr>
.TE
.SH 3
Search Techniques
.LP
.LP
There are several different motion vector search techniques
available. There are different techniques available for P frame
search and B frame search. Using different search techniques present
little difference in quality, but a large difference in compression
and speed.
.LP
There are 4 types of P frame search: Exhaustive, TwoLevel,
SubSample, and Logarithmic.
.LP
There are 3 types of B frame search: Exhaustive, Cross2, and
Simple.
The recommended search techniques are TwoLevel and Logarithmic for
P frame search, and Cross2 and Simple for B frame search. Here are
some numbers comparing the different search methods:
.TS
center ;
P frame Motion Vector Search (Normalized)
<?makeman r c c c. ?>
<?makeman _ ?>
<tr align="center">
<th>
Technique</th>
<th>
Compression<sup>
1</sup>
</th>
<th>
Speed <sup>
2</sup>
</th>
<th>
Quality <sup>
3</sup>
</th>
</tr>
<tr>
<td align="right">
Exhaustive</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
</tr>
<tr>
<td align="right">
SubSample</td>
<td align="center">
1008</td>
<td align="center">
2456</td>
<td align="center">
1000</td>
</tr>
<tr>
<td align="right">
TwoLevel</td>
<td align="center">
1009</td>
<td align="center">
3237</td>
<td align="center">
1000</td>
</tr>
<tr>
<td align="right">
Logarithmic</td>
<td align="center">
1085</td>
<td align="center">
8229</td>
<td align="center">
998</td>
</tr>
.TE
.TS
center ;
B frame Motion Vector Search (Normalized)
<?makeman r c c c. ?>
<?makeman _ ?>
<tr align="center">
<th>
Technique</th>
<th>
Compression<sup>
1</sup>
</th>
<th>
Speed<sup>
2</sup>
</th>
<th>
Quality<sup>
3</sup>
</th>
</tr>
<tr>
<td align="right">
Exhaustive</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
</tr>
<tr>
<td align="right">
Cross2</td>
<td align="center">
975</td>
<td align="center">
1000</td>
<td align="center">
996</td>
</tr>
<tr>
<td align="right">
Simple</td>
<td align="center">
938</td>
<td align="center">
1765</td>
<td align="center">
991</td>
</tr>
.TE
<sup>
1</sup>
Smaller numbers are better
compression.
<sup>
2</sup>
Larger numbers mean faster
execution.
<sup>
3</sup>
Larger numbers mean better quality.
.LP
For some reason, Simple seems to give better compression, but it
depends on the image sequence.
.LP
Select the search techniques with the \fBPSEARCH_ALG\fR and
\fBBSEARCH_ALG\fR parameter file statements.
.SH 3
Group Of Pictures (GOP)
.LP
.LP
A Group of Pictures (GOP) is a roughly independently decodable
sequence of frames. An MPEG video stream is made of one or more
GOP's. You may specify how many frames should be in each GOP with the
\fBGOP_SIZE\fR parameter file statement. A GOP always starts with an
I frame.
.LP
Instead of encoding an entire sequence, you can encode a single
GOP. To do this, use the \fB-gop\fR command option. You can later
join the resulting GOP files at any time by running \fBppmtompeg\fR
with the \fB-combine_gops\fR command option.
.SH 3
Slices
.LP
.LP
A slice is an independently decodable unit in a frame. It can be
as small as one macroblock, or it can be as big as the entire frame.
Barring transmission error, adding slices does not change quality or
speed; the only effect is slightly worse compression. More slices are
used for noisy transmission so that errors are more recoverable. Since
usually errors are not such a problem, we usually just use one slice
per frame.
.LP
Control the slice size with the \fBSLICES_PER_FRAME\fR parameter
file statement.
.LP
Some MPEG playback systems require that each slice consist of whole
rows of macroblocks. If you are encoding for this kind of player, if
the height of the image is H pixels, then you should set the
SLICES_PER_FRAME to some number which divides H/16. For example, if
the image is 240 pixels (15 macroblocks) high, then you should use
only 15, 5, 3, or 1 slices per frame.
.LP
Note: these MPEG playback systems are really wrong, since the MPEG
standard says this doesn't have to be so.
.SH 3
Search Window
.LP
.LP
The search window is the window in which \fBppmtompeg\fR searches
for motion vectors. The window is a square. You can specify the size
of the square, and whether to allow half-pixel motion vectors or not,
with the \fBRANGE\fR and \fBPIXEL\fR parameter file statements.
.SH 3
I Frames, P Frames, B Frames
.LP
.LP
In MPEG-1, a movie is represented as a sequence of MPEG frames,
each of which is an I Frame, a P Frame, or a B Frame. Each represents
an actual frame of the movie (don't get confused by the dual use of
the word "frame." A movie frame is a graphical image. An MPEG frame
is a set of data that describes a movie frame).
.LP
An I frame ("intra" frame) describes a movie frame in isolation --
without respect to any other frame in the movie. A P frame
("predictive" frame) describes a movie frame by describing how it
differs from the movie frame described by the latest preceding I or
P frame. A B frame ("bidirectional" frame) describes a movie frame by
describing how it differs from the the movie frames described by the
nearest I or P frame before and after it.
.LP
Note that the first frame of a movie must be described by an I
frame (because there is no previous movie frame) and the last movie
frame must be described by an I or P frame (because there is no
subsequent movie frame).
.LP
Beyond that, you can choose which frames are represented by which
types. You specify a pattern, such as IBPBP and \fBppmtompeg\fR
simply repeats it over and over throughout the movie. The pattern
affects speed, quality, and stream size. Here is a chart which shows
some of the trade-offs:
.TS
center ;
Comparison of I/P/B Frames (Normalized)
<?makeman r c c c. ?>
<?makeman _ ?>
<tr align="center">
<th>
Frame Type</th>
<th>
Size</th>
<th>
Speed</th>
<th>
Quality</th>
</tr>
<tr>
<td align="right">
I frames</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
<td align="center">
1000</td>
</tr>
<tr>
<td align="right">
P frames</td>
<td align="center">
409</td>
<td align="center">
609</td>
<td align="center">
969</td>
</tr>
<tr>
<td align="right">
B frames</td>
<td align="center">
72</td>
<td align="center">
260</td>
<td align="center">
919</td>
</tr>
.TE
(this is with constant qscale)
.LP
A standard sequence is IBBPBBPBBPBBPBB.
.LP
Select the sequence with the \fBPATTERN\fR parameter file statement.
.LP
Since the last MPEG frame cannot be a B frame (see above), if the
pattern you specify indicates B frames for the last movie frames,
\fBppmtompeg\fR makes it an I frame instead.
.LP
Before Netpbm 10.26 (January 2005), \fBppmtompeg\fR instead drops
the trailing B frames by default, and you need the
\fBFORCE_ENCODE_LAST_FRAME\fR parameter file statement to make it do
this.
.LP
The MPEG frames don't appear in the MPEG-1 stream in the same order that
the corresponding movie frames appear in the movie -- the B frames come after
the I and P frames on which they are based. For example, if the movie is
4 frames that you will represent with the pattern IBBP, the MPEG-1 stream
will start with an I frame describing movie frame 0. The next frame in
the MPEG-1 stream is a P frame describing movie frame 3. The last two
frames in the MPEG-1 stream are B frames describing movie frames 1 and 2,
respectively.
.SH 3
Specifying Input and Output Files
.LP
.LP
Specify the input frame images with the \fBINPUT_DIR\fR,
\fBINPUT\fR, \fBEND_INPUT\fR, \fBBASE_FILE_FORMAT\fR,
\fBSIZE\fR, \fBYUV_FORMAT\fR and \fBINPUT_CONVERT\fR parameter
file statements.
.LP
Specify the output file with the \fBOUTPUT\fR parameter file statement.
.SH 3
Statistics
.LP
.LP
\fBppmtompeg\fR can generate a variety of statistics about the
encoding. See the \fB-stat\fR, \fB-snr\fR, \fB-mv_histogram\fR,
\fB-quiet\fR, \fB-no_frame_summary\fR, and \fB-bit_rate_info\fR
options.
.SH 2
PARALLEL OPERATION
.LP
.LP
You can run \fBppmtompeg\fR on multiple machines at once, encoding
the same MPEG stream. When you do, the machines are used as shown in
the following diagram. We call this "parallel mode."
.LP
.LP
To do parallel processing, put the statement
.DS L
PARALLEL
.DE
in the parameter file, followed by a listing of the machines, one
machine per line, then
.DS L
END_PARALLEL
.DE
Each of the machine lines must be in one of two forms. If the machine
has filesystem access to the input files, then the line is:
.LP
\fImachine\fR \fIuser\fR \fIexecutable\fR
.LP
The executable is normally \fBppmtompeg\fR (you may need to give
the complete path if you've built for different architectures). If
the machine does not have filesystem access to the input files, the line
is:
.LP
\fBREMOTE\fR \fImachine\fR \fIuser\fR \fIexecutable\fR
\fIparameter file\fR
.LP
The \fB-max_machines\fR command option limits the number of
machines \fBppmtompeg\fR will use. If you specify more machines in
the parameter file than \fB-max_machines\fR allows, \fBppmtompeg\fR
uses only the machines listed first. This is handy if you want to
experiment with different amounts of parallelism.
.LP
In general, you should use full path file names when describing
executables and parameter files. This includes the parameter
file argument on the original invocation of \fBppmtompeg\fR.
.LP
All file names must be the same on all systems (so if e.g. you're
using an NFS filesystem, you must make sure it is mounted at the same
mountpoint on all systems).
.LP
Because not all of the processes involved in parallel operation
have easy access to the input files, you must specify the \fBSIZE\fR
parameter file statement when you do parallel operation.
.LP
The machine on which you originally invoke \fBppmtompeg\fR is the
master machine. It hosts a "combine server,", a
"decode server," and a number of "i/o servers,"
all as separate processes. The other machines in the network (listed
in the parameter file) are slave machines. Each hosts a single
process that continuously requests work from the master and does it.
The slave process does the computation to encode MPEG frames. It
processes frames in batches identified by the master.
.LP
The master uses a remote shell command to start a process on a
slave machine. By default, it uses an \fBrsh\fR shell command to do
this. But use the \fBRSH\fR parameter file statement to control
this. The shell command the master executes remotely is
\fBppmtompeg\fR, but with options to indicate that it is to perform
slave functions.
.LP
The various machines talk to each other over TCP connections. Each
machine finds and binds to a free TCP port number and tells its
partners the port number. These port numbers are at least 2048.
.LP
Use the PARALLEL_TEST_FRAMES, PARALLEL_TIME_CHUNKS, and
PARALLEL_PERFECT parameter file statements to control the way the
master divides up work among the slaves.
.LP
Use the \fB-nice\fR command option to cause all slave processes to run
"nicely," i.e. as low priority processes. That way, this substantial and
long-running CPU load will have minimal impact on other, possibly
interactive, users of the systems.
.SH 2
SPEED
.LP
.LP
Here is a look at \fBppmtompeg\fR speed, in single-node (not parallel)
operation:
.TS
center ;
Compression Speed
<?makeman r c. ?>
<?makeman _ ?>
<tr align="center">
<th>
Machine Type</th>
<th>
Macroblocks per second<sup>
1</sup>
</th>
</tr>
<tr>
<td align="right">
HP 9000/755</td>
<td align="center">
280</td>
</tr>
<tr>
<td align="right">
DEC 3000/400</td>
<td align="center">
247</td>
</tr>
<tr>
<td align="right">
HP 9000/750</td>
<td align="center">
191</td>
</tr>
<tr>
<td align="right">
Sparc 10</td>
<td align="center">
104</td>
</tr>
<tr>
<td align="right">
DEC 5000</td>
<td align="center">
68</td>
</tr>
.TE
<sup>
1</sup>
A macroblock is a 16x16 pixel square
.LP
The measurements in the table are with inputs and outputs via a
conventional locally attached filesystem. If you are using a network
filesystem over a single 10 MB/s Ethernet, that constrains your speed more
than your CPU speed. In that case, don't expect to get better than 4
or 5 frames per second no matter how fast your CPUs are.
.LP
Network speed is even more of a bottleneck when the slaves do not
have filesystem access to the input files -- i.e. you declare them
REMOTE.
.LP
Where I/O is the bottleneck, size of the input frames can make a big
difference. So YUV input is better than PPM, and JPEG is better than
both.
.LP
When you're first trying to get parallel mode working, be sure to
use the \fB-debug_machines\fR option so you can see what's going on.
Also, \fB-debug_sockets\fR can help you diagnose communication
problems.
.SH 2
AUTHORS
.LP
.IP \(bu
Kevin Gong - University of California, Berkeley, keving@cs.berkeley.edu
.IP \(bu
Ketan Patel - University of California, Berkeley, kpatel@cs.berkeley.edu
.IP \(bu
Dan Wallach - University of California, Berkeley, dwallach@cs.berkeley.edu
.IP \(bu
Darryl Brown - University of California, Berkeley, darryl@cs.berkeley.edu
.IP \(bu
Eugene Hung - University of California, Berkeley, eyhung@cs.berkeley.edu
.IP \(bu
Steve Smoot - University of California, Berkeley, smoot@cs.berkeley.edu
.LP
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
SYNOPSIS
.IP \(bu
DESCRIPTION
.IP \(bu
OPTIONS
.IP \(bu
PARAMETER FILE
.IP \(bu
GENERAL USAGE INFORMATION
.IP \(bu
PARALLEL OPERATION
.IP \(bu
SPEED
.IP \(bu
AUTHORS
.LP
|