[MEncoder-users] Re: mp4/h264 encoding status

Jon Drukman jsd at cluttered.com
Tue Oct 31 19:44:22 CET 2006


Karl Mitchell wrote:
> Hi,
> 
> A quick question.  I've been out of the loop with mencoder builds for a 
> while.  What is the state of play with mp4/h264 encoding.  Last thing I 
> remember, there were problems with bframes that necessitated using the 
> "i_certify_that_i_do_not_use_bframes" option, and an audio-video muxing 
> workaround using MP4Box.  Is this still the same?  I'm trying to 
> automate postprocessing of HDTV/ATSC mpeg-2 transport streams.

correct.  if you want to use H.264 with B-frames, you need to output 
rawvideo and use an external muxer.  i'm using mp4creator - i had 
problems with mp4box and quicktime compatibility (some videos just would 
not play in QT for no reason that i could see - but muxing the exact 
same a/v streams with mp4creator played fine in QT)

here's my current H.264-in-mp4 script.  you will need mencoder, ffmpeg 
and mp4creator.  (if someone can figure out how to use mencoder to 
generate just an .aac audio stream (no video) then you can replace the 
ffmpeg step with that and save yourself compiling yet another app.)

MUXER="-of rawvideo"
VIDEO="-sws 9 -vf 
harddup,scale=640:368,smartblur=.6:-.3:0,unsharp=l3x3:1:c3x3:1:analyse=0x1:0:deblock=0:0:0,softskip,hue=0:1.3 
-ovc x264 -ofps 30000/1001"
AUDIO="-nosound"
MENC="./mencoder $1 -o video.264"

$MENC $MUXER $VIDEO $AUDIO -x264encopts 
bitrate=1750:subq=6:partitions=all:me=umh

# encode audio to aac

rm -f audio.aac
/opt/bin/ffmpeg -y -i "$1" -vn -f aac -ar 48000 -ab 128 -coder 0 -ac 2 
-acodec aac audio.aac

rm -f "$1.mp4"
/opt/bin/mp4creator -c audio.aac "$1.mp4"
/opt/bin/mp4creator -rate 29.97 -c video.264 "$1.mp4"

rm -f audio.aac divx2pass.log video.264


If you want two do two pass encoding, change the $MENC $MUXER... line to:

rm -f video.264 divx2pass.log
$MENC $MUXER $VIDEO $AUDIO -x264encopts 
bitrate=1750:subq=1:frameref=1:pass=1:turbo=1
$MENC $MUXER $VIDEO $AUDIO -x264encopts 
bitrate=1750:subq=6:frameref=15:partitions=all:me=umh:pass=2


You can play around with eliminating the frameref=15 option - it slows 
things way down for not much noticeable benefit at this resolution/bitrate.

-jsd-




More information about the MEncoder-users mailing list