MPEG movie encoding on a Linux box?

There is a way to generate MPEG movies containing full motion video and stereo audio from a program like Broadcast 2000 on a Linux box. Since MPEG-I is an obsolete standard there isn't much effort going into a front end for the encoding. The encoding sequence is hard but you really aren't doing video until you write MPEG files.

Encoding the video

Basically you render a list of JPEG images for the Berkeley video encoder which is in the video_in directory. The images must be one of the legal frame rates in the parameters file. The bit rate must be 1000000. And the horizontal and vertical dimensions must be multiples of 16. Other frame sizes cause mpeg_encode to crash.

Encoding the audio

Render a 16 bit, big endian, PCM file for the ISO MPEG audio encoder in audio_in. The audio must be 44100Hz and either 1 or 2 channels. Encode the audio in a 192 kbit, layer II file using the encoder in audio_in.

Multiplex into an mpeg system stream

The resulting MPEG files are multiplexed into an mpeg system stream, the kind you download on the internet, using the mplex program in mplex_in.

This tarball contains all the command line utilities you need, as distributed by their respective authors, with minimal alterations. This means any Makefile hacking must be done seperately in each directory. More stuff can be found on the Heroine Virtual page.

For the audio encoder I run a tuned script in the audio_in directory that invokes the encoder with certain parameters.

Next I run the Berkeley encoder by issuing mpeg_encode parameters in the video_in directory, with a tuned parameters file.

Finally comes the multiplexing stage in the multiplex directory. Run the multiplexer to get a usage statement. It's pretty self explanatory.

Now it's time to make your Linux box go the other way.

MPEG movie extraction on a Linux box?

Encoding MPEG movies is fine and dandy, but what if you want to extract your hard earned footage from the MPEG stream or edit some MPEG movie you download from the internet?

A second set of tools is included in the MPEG Movie package for extracting uncompressed data from MPEG streams. Unlike the compression tools, the decompression tools are heavily modified. Not as many people want to edit MPEG movies as those who just want to watch them. The success of MPEG extraction is a bit worse than MPEG compression mainly because of the wide variety of MPEG standards on the internet. Streams created with my package seem to extract every time, however.

Simply run plaympeg -e input stream in the audio_out directory to extract the audio into a raw, 16 bit PCM file of 1 or 2 channels. Since smpeg's video decoding doesn't work perfectly, we couldn't use it for video extraction.

Run dmplex input stream output file in the mplex_out directory to first get a video-only MPEG stream. Most of the time this program locks up after exporting the video. Hit Ctrl-C if it locks up after your output file stops growing.

Then run mpeg_play -e input stream in the video_out directory to get the video into a Quicktime movie. The extraction parameter takes an optional codec argument. The codec argument specifies which format to save the images in, in the output file. For a list of codecs type mpeg_play -h. Also, if you extract a movie with a non-standard frame size, you might get garbage on the borders.

Voila! Quit your job at ILM, you've got an MPEG movie studio at home.

Harass the author at broadcast@earthling.net

(C)2000 Adam Williams