MPEG-2 MOVIE

Building the source code
The theory behind making MPEG movies
Generating the source movies
Encoding the video
Encoding the audio
Multiplex the streams
MPEG3CAT: a useful utility
Creating Microsoft compliant output
Troubleshooting

MPEG-4 encoding on a Linux box? NO WAY!
One of the better kept secrets of the internet is that what you know as MPEG-4 is really a wrapper for MPEG-1 with some very minor improvements. The improvement between MPEG-4 and MPEG-1 came from optimizations Microsoft performed on the MPEG-1 compressor. Indeed the compressor has the biggest impact on the quality of any format regardless of the title of the standard.

MPEG-2 Movie allows you to synthesize very low bitrate audio and video streams from Quicktime movies and multiplex them into a single program stream. Since these MPEG-2 encoders are fairly obsolete and don't give the same quality as Microsoft, this package contains all the command line utilities needed, but no interface to integrate them all.


Building the source code
Requires the following point releases:

Linux 2.4.0
gcc-2.96 and above.
libc-2.1.94
NASM 0.98 and above.
Configure and build:

Run ./configure in the top directory.
Run Make

There is no installation sequence. The programs are supposed to be run in their directories. Your best improvement is to modify the example script file.


The theory behind making MPEG movies
You synthesize MPEG movies by first encoding elemental audio and video streams and then multiplexing them. MPEG-2 movie can multiplex any combination of the following streams into a movie:

MPEG-1 layer II audio
MPEG-1 layer III audio
MPEG-2 layer III audio
MPEG-1 video
MPEG-2 video

Step 1: Generating the source movies
MPEG-2 movie's video encoders only take Quicktime movies. You need to synthesize uncompressed Quicktime movies containing the video data to use the video encoder. The audio encoders take uncompressed 16 bit WAV files.

Encoding Recommended Encoder Input file format
MPEG-1 layer II audio audiomp2/toolame Microsoft WAV
MPEG-1 layer III audio audiomp3/lame Microsoft WAV
MPEG-2 layer III audio audiomp3/lame Microsoft WAV
MPEG-1 video video/encode Uncompressed Quicktime
MPEG-2 video video/encode Uncompressed Quicktime

The framerate you choose must be one of the following:

24000.0/1001.0  // Official rates supported by MPEG
24.0
25.0
30000.0/1001.0
30.0
50.0
60000.0/1001.0
60.0

1           // Supported by MPEG-2 movie but not by MPEG
5
10
12 
15
The unofficial economy rates were developed for unemployed programmers and internet enthusiasts who can't afford enough space for the high official frame rates.

By the way, a good way to synthesize Quicktime movies on Linux is Broadcast 2000. With the movie rendered, it's time to encode it.


Encoding the video
Encoding the lowest bitrate, highest quality video is more an artform than a computer science discipline. MPEG-2 movie's encoder produces MPEG-1, MPEG-2, fixed bitrate/variable quantization, variable bitrate/fixed quantization, progressive frame, or interlaced frame video streams. With variable keyframe distances for good measure.

Run encode in the video directory to get a parameter listing.

Desired content Recommended input format Recommended encoding parameters
Internet documentary 320x240 15fps -1 -q 20 -n 300 -m 0
Internet trailer 640x480 24fps -1 -q 30 -n 300 -m 0
Fast motion low bitrate 640x480 24fps -1 -q 30 -n 300 -m 0
Still images low bitrate 640x480 24fps -1 -b 1000000 -m 0
Fast motion high bitrate 720x480 29.97fps -q 5
Still images high bitrate 720x480 29.97fps -b 5000000
Archive high bitrate 720x480 29.97fps -q 1


Encoding the audio
You should all be experts in MP3 encoding. The audio must be in 16 bit Microsoft WAV format. There are two audio encoders. For low bitrate encoding use audiomp3. For high bitrate encoding use audiomp2.

Desired content Recommended encoder Recommended encoding parameters
Internet documentary audiomp3/lame -h -b 32
Internet trailer audiomp3/lame -h -b 64
48000Hz low bitrate audiomp3/lame -h -b 128
48000Hz high bitrate audiomp2/toolame -b 320 -m s


Final step: Multiplex the streams
Run mplexlow/mplex to multiplex the video and audio streams into a single program stream. The Tiny Mplex program basically decompresses all the streams to synchronize the sound and video, and writes packets. This multiplexer is designed for variable bitrate streams so its output won't work in Microsoft Media Player.


MPEG3CAT: a useful utility
If you have a cluster of machines you can render several Quicktime movies and encode one MPEG stream for each on a different computer. Before multiplexing, you'll need to concatenate all the streams into a single video file. Run mpeg3cat in the libmpeg3 directory to do this. The usage is the same as ordinary cat.


Creating Microsoft compliant output
Unless you plan on only watching movies in Linux you'll need to conform your encoding to the Microsoft Media Player. This player accepts only fixed bitrate video and audio multiplexed with the mplexhi/mplex program. The encoding is rigid:
Stream Encoder Encoding parameters
Audio audiomp2/toolame -b 192
Video video/encode -1 -b 1000000 -m 2
Multiplex mplexhi/mplex

Harass the author at
broadcast@earthling.net

(C)2000 Adam Williams