DivX Mode

divx

in this mode encode2mpeg creates a DivX avi with MEncoder. The output video stream is mpeg4 or a copy of the input video stream, the output audio stream can be mp2, mp3, ac3, pcm  or a copy of the input audio stream.  This mode is selected with the options: -avionly -encode.
The argument of -encode selects the different audio/video encode options. It has the form n:m:i[,b]

n can be:
0 - copy of the input audio stream (-oac copy)
1 - pcm audio stream (-oac pcm)
2 - mp3lame fast (-oac mp3lame -lameopts fast)
3 - mp3lame standard (-oac mp3lame -lameopts preset=standard)
4 - mp2/libavcodec (-oac lavc -lavcopts acodec=mp2:abitrate=224)
5 - mp3/libavcodec (-oac lavc -lavcopts acodec=mp3:abitrate=224)
6 - ac3/libavcodec (-oac lavc -lavcopts acodec=ac3:abitrate=224)
7 - mp2/toolame (-oac toolame -toolameopts br=224)
Note: the audio bit rate can be specified in two ways: with the options -abr or with a comma and the bitrate as part of the -encode argument.
-encode 5:1:1,128
 or
-encode 5:1:1 -abr 128
are equivalent in DivX Mode

m can be:
0 - copy of the input video stream (-ovc copy)
1 - libavcodec/mpeg4 (-ovc lavc -lavcopts vcodec=mpeg4:autoaspect:vbitrate=16000:psnr)
2 - as 1 + mbd=2 (mbd=2:keyint=300)
3 - as 1 + compression options (mbd=1:vmax_b_frames=2:last_pred=5:aic:mv0:vlelim=-4:vcelim=7:v4mv:preme=2:keyint=300)
4 - as 1 + quality options (mbd=2:trell:v4mv:mv0:aic:last_pred=5:precmp=3:cmp=3:subcmp=3)

i can be 1, 2 or 3 and select the number of encoding pass.

-encode can have also only one numeric parameter: 1-4.
-encode 1 is equivalent to -encode 3:2:1 (fast good quality 1 pass mode)
-encode 2 is equivalent to -encode 3:2:2 (quite fast good quality 2 pass mode)
-encode 3 is equivalent to -encode 3:3:2 (slow good compression 2 pass mode)
-encode 4 is equivalent to -encode 3:4:2 (slow very good quality 2 pass mode)

Other options usefull in DivX Mode:
-vfr or -ofps (output frame rate)
-multiaudio (avi with more than one audio stream, you need avimerge)
-monochrome
-avisplit (split the avi in chunk of fixed size, you need avisplit)
-bframes (number of B frames, used if m = 3)
-vbitrate (video bit rate)
-vcustom (custom video lavc options, used if m = 1)
-acustom (custom audio mpelame options, used if n = 2)
-usesbr (set the size of the avi file)
-setaspect (scale the video and keep the correct aspect ratio)
-crop <w:h:x:y> (crop window)
-autocrop (autodetect the crop window)
-interlaced (use it if your source video is interlaced)
-fixavi (used if m = 0)
-cpu <1-8>
-channels <1-6> (select the number of channels in the avi audio stream. This is an MEncoder option but it's intercepted and handled by encode2mpeg. mp2/mp3 can have 1-2 channels, ac3/lpcm 1-6 channels)
-qmatrix (select kvcd or tmpgenc quantization matrices)
-turbo <0|1> (disable or force turbo mode)

Hint

DivX Mode is meant to be used for storage purpose. For example you have a DVD movie and you want to reduce the disk space required. You can have different goals: speed, high compression, high quality. In all cases I wanted to preserve in the DivX video as much as possible the quality of the source video and then I set the video bitrate of the mpeg4 stream very high: 16000. As you will see later, putting a limitation on the video bit rate has a bad impact on the PSNR more than using other libavcodec options. So it's always better to leave it very high, unless your have no other choises and you have to reduce it (for example for a fixed size file or if the video bit rate exceed the capability of your hardware player).

Comparison

See TABLE 1 for a comparison of -encode 1-4.
See TABLE 2 for a comparison between different number of B frames with -encode 3.
See TABLE 3 for a comparison between different -encode and -setaspect optiond with -usesbr 2 (1 CD file size).
See TABLE 4 for a comparison between different -encode and -setaspect optiond with -usesbr 5 (2 CD file size).

Threads

encode2mpeg takes advantage of systems with multiple cpu. It uses as many threads as the number of cpu present. See TABLE 5 for a comparison. You can specify explicitely the number of threads (up to 8) with -cpu <n>. Linux 2.4.x has poor support for hyperthreading cpu. Because of that, on systems with kernel 2.4.x, one physical cpu and hyperthreading turnded on, the default is to use only one thread. You can override it with -cpu 2.

Examples

encode2mpeg -o fastonecd dvd://1 -aid 128 -avi -encode 2 -usesbr 2 -setaspect 4
encode a dvd to a 700MB avi with fast 2 pass mode with resolution 384x224. Log file.

encode2mpeg -o divx dvd://1 -multiaudio 128,129 -avi -encode 0:4:2 -encsid 0,2,4 -encsdx 0,1,2 -encsla en,fr,es
encode a dvd with the best quality keeping two ac3 audio streams and dumping three subtitles. Log file.