next up previous contents
Next: Internet Links Up: Video on the World Previous: SHHVid Proxy Source Code

Recoding MPEG to JPEG and GIF

  This appendix explains the method used for converting MPEG streams to GIF and JPEG files in chapter 2.5 on page gif. After shortly describing the tools used, figure E.1 presents the script used to do the actual conversion.

The MPEG streams were decoded using Andy Hung's MPEG codec, which translates from a single MPEG file, to three files for each frame of the movie. The three files, given extensions .Y, .U and .V, contains the three components from the YUV (or actually YCbCr) color space of the frame in question.

PPM (Portable PixMap file format) was chosen as an intermediate format during conversion, since fully command line driven support programs are available, simplifying conversion of a large number of files. A large collection of support programs, known as netpbm, provides conversion between many popular image file formats, in addition to elementary image processing.

Matching YUV-files were combined into a single PPM-file using cyuv2ppm, also written by Andy Hung.

Conversion from PPM to JPEG was done with Independent JPEG Group's program cjpeg, found in the package jpegsrc.v6a.tar.gz.

GIF-conversion was performed in two steps. The first step quantized the image to 256 colors, the maximum number of colors in a GIF image. Quantization was done using ppmquant. The second step converted the quantized PPM image to GIF using ppmtogif. Both programs can be found in the above mentioned netpbm package.

The shell script in the following figure, decodes a single MPEG file, given it's name and horizontal and vertical frame sizes. After decoding to a number of YUV-files, the conversion to JPEG and GIF is done, followed by removal of all intermediate files. Note that cjpeg defaults to a quality of 75. The quality settings range from 0 (worst) to 100 (best), and the number given is used to scale the quantization tables.

  figure2448
Figure E.1:  Shell-script used to recode the MPEG files to JPEG and GIF.


next up previous contents
Next: Internet Links Up: Video on the World Previous: SHHVid Proxy Source Code

Sverre H. Huseby
Sun Feb 2 15:54:02 MET 1997