Web Projects Consulting

Mencoder Two-Pass Encoding with Mpeg4 Codec

Command line encoding of an input MPEG2 file into an mp4 format (XViD) in Linux.

# remove conflicting files
rm -f divx2pass.log frameno.avi
# rip audio track (bitrate: 192, gain: 0)
mencoder -oac mp3lame -lameopts mode=0:cbr:br=192:vol=0 \
-ovc frameno -o frameno.avi  [input].mpg
# video track (pass: 1, bitrate: 1800)
mencoder -sws 2 -oac copy -ovc lavc -lavcopts  \
vcodec=mpeg4:vbitrate=1800:vhq:vpass=1 -ffourcc XVID -vf \
crop=704:560:6:10,scale=720:756  [input].mpg -o /dev/null
# video track (pass: 2, bitrate: 1800)
mencoder -sws 2 -oac copy -ovc lavc -lavcopts \
vcodec=mpeg4:vbitrate=1800:vhq:vpass=2 -ffourcc XVID -vf \
crop=704:560:6:10,scale=720:756  [input].mpg -o "[output].avi"
Tagged on: , , ,

2 thoughts on “Mencoder Two-Pass Encoding with Mpeg4 Codec

  1. Alec

    Yes, there are issues with that.
    However, the article is quite outdated, I would do it differently already, something like:

    mencoder -v -noskip 
            -vf crop=720:352:0:64,scale=752:320 
            -ovc x264 -x264encopts subq=5:bframes=4:b_pyramid:weight_b:pass=1:psnr:bitrate=1500:turbo=1:bime 
            -oac copy 
            -ofps 24000/1001 
            -vobsubout subtitles -vobsuboutindex 0 -slang en 
            -o /dev/null
    mencoder -v -noskip 
            -vf crop=720:352:0:64,spp,scale=752:320,hqdn3d=2:1:2 
            -ovc x264 -x264encopts subq=5:partitions=4x4:8x8dct:frameref=3:me=hex:bframes=4:b_pyramid:pass=2:psnr:bitrate=1500:bime 
            -oac faac -faacopts object=1:tns:quality=100 
            -ofps 24000/1001 
            -o title1.avi

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.