mencoder :: xvid compression multipass

Sometimes it is necessary to compress video. My preferred codec is XviD, because its GPL.
With the following script the 2 pass encoding is done automatic.


# Audio preprocessing
mencoder $infile -ovc frameno -oac mp3lame -lameopts vbr=3 -o frameno.avi -quiet

# 2pass
mencoder $infile -ovc xvid -xvidencopts bitrate=$bitrate:pass=1 
 -vf pp=tn/lb/hb/vb -oac copy -o /dev/null
mencoder $infile -ovc xvid -xvidencopts bitrate=$bitrate:pass=2 
 -vf pp=tn/lb/hb/vb -oac copy -o $outfile

# remove trash
rm -f frameno.avi xvid-twopass.stats

call it with ./ inputfilename outputfilename bitrate.
It needs twice as long as normal compression but the result is quite better.