Making mpegs


First thing is to make sure you have a mpg encoder installed. One of the standards is Berkeley's encoder mpeg_encode. On the new Linux machines at USYD, this is no longer functional, so we went to ppmtompeg..

This has its own share of issues: the one that came with our redhat distribution didn't work, so we had to compile it from scratch. Just warning...


Now you have an encoder happening, you need an input file.


A good description of the input file can be found here:

http://docsrv.caldera.com:8457/cgi-bin/man?mansearchword=ppmtompeg&mansection=1


Here's an example of what it should look like:


PATTERN I

OUTPUT overturn2.mpg

BASE_FILE_FORMAT PPM

INPUT_CONVERT *

GOP_SIZE 650

SLICES_PER_FRAME 1

INPUT_DIR .

INPUT

epi.*.ppm0 [00005-03000+5]

END_INPUT

PIXEL HALF

RANGE 10

PSEARCH_ALG LOGARITHMIC

BSEARCH_ALG CROSS2

IQSCALE 8

PQSCALE 10

BQSCALE 25

REFERENCE_FRAME ORIGINAL



PATTERN: This is about the encoding of frames. This statement specifies the pattern (sequence) of I frames, P frames, and B frames. is just a sequence of the letters I, P, and B with nothing between. Checkout:

http://www.cvc.mun.ca/software/netpbm/doc/ppmtompeg.html#ipb


Here the output mpg is overturn2.mpg. The image files must be one of a few formats, of which ppms are the easiest to convert. If you have files in another format, you can use convert command to turn then into ppms manually. Alternatively, you can use the input_covert tag to do it for some formats on the fly, eg:

INPUT_CONVERT giftoppm *


GOP_SIZE 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 http://www.cvc.mun.ca/software/netpbm/doc/ppmtompeg.html#gop


SLICES_PER_FRAME 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.


INPUT_DIR directory all input files must reside in this directory. If you want to refer to the current directory, use '.' A null directory refers to the root directory. If input files will be coming in from standard input, use 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. Secondly, the line may be of the form

single_star_expr

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.

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).

Good luck.

Back to http://www.geosci.usyd.edu.au/users/craig/