[MEncoder-users] problem with h264/aac .mp4

James Hastings-Trew jimht at shaw.ca
Wed Jun 11 06:02:29 CEST 2008


Alex Samad wrote:
> Hi
>
> I have encoded some mpg to mp4 with 
> nice mencoder -really-quiet  -aspect 16:9    -vf
> scale=::::::qpal,hqdn3d=2:1:2,pp=de,uspp=5,harddup  -af volnorm=1  -ovc
> x264  -x264encopts
> pass=1:turbo=2:nob_pyramid:bframes=1:subq=6:frameref=3:partitions=all:me=umh:weight_b:threads=auto:qcomp=0.75:mixed_refs:nofast_pskip:trellis=2:nodct_decimate:nopsnr:brdo:bitrate=220
> -oac faac  -faacopts object=2:tns:mpeg=4  -passlogfile
> "/tmp/user/1000/myConvert.7GX8P/divx2pass.log" -o /dev/null
> "/home/alex/VideoCamera/src/video/by-date/20071019094844-MOV001_19.mpg"
> -idx   
>
>
> nice mencoder -really-quiet  -aspect 16:9    -vf
> scale=::::::qpal,hqdn3d=2:1:2,pp=de,uspp=5,harddup  -af volnorm=1  -ovc
> x264  -x264encopts
> pass=2:nob_pyramid:bframes=1:subq=6:frameref=3:partitions=all:me=umh:weight_b:threads=auto:qcomp=0.75:mixed_refs:nofast_pskip:trellis=2:nodct_decimate:nopsnr:brdo:bitrate=220
> -oac faac  -faacopts object=2:tns:mpeg=4  -passlogfile
> "/tmp/user/1000/myConvert.7GX8P/divx2pass.log" -o
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19.avi"
> "/home/alex/VideoCamera/src/video/by-date/20071019094844-MOV001_19.mpg"
> -idx   
>
>  MP4Box -aviraw video
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19.avi" -out
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19.h264"
>
> nice MP4Box -aviraw audio
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19.avi" -out
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19.aac"
>
> nice  mv
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19_audio.raw"
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19_audio.aac"
>
>
> nice MP4Box -add
> "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19_video.h264"
> -add "/tmp/user/1000/myConvert.7GX8P/20071019094844-MOV001_19_audio.aac"
> -new "20071019094844-MOV001_19.mp4"
>
> when i play these output file back with mplayer everything plays okay,
> but when I try to rewind to the beginning (has to be to the beginning )
>
> I get these errors
> [h264 @ 0xb3f440]warning: first frame is no keyframe ??% ??,?% 0 0 
> pts value <= previous: -0.313 ct: -0.032   0/  0 ??% ??% ??,?% 0 0 
>
> and the picture goes all crappy and eventually come good
>
> what am missing / I doing wrong ?
>
>
> alex
>   
A few problems:
Your video bitrate is improbably low, unless you are doing really tiny 
files. Try increasing it to 800 or more.

You have to specify the frame rate of the video stream to mp4box. Raw 
h.264 streams contain no information about framerate.

You have a lot of options in your -x264encodeopts that you might not 
understand why you are using them, yet you don't specify the idc_level. 
Try sticking to the basics first, get things working, and then tinker 
with the extra options later. I use:

//pass 1
-x264encopts 
bitrate=2500:vbv_maxrate=5000:vbv_bufsize=1200:bframes=3:nocabac:nofast_pskip:frameref=1:subq=1:level_idc=31:threads=auto:pass=1:turbo
//pass 2
-x264encopts 
bitrate=2500:vbv_maxrate=5000:vbv_bufsize=1200:bframes=3:partitions=all:me=umh:nocabac:nofast_pskip:frameref=6:subq=6:level_idc=31:threads=auto:pass=2

Or, if you don't really care about peak bitrate or filesize, and want to 
do it in one pass:
// one pass
-x264encopts 
qp=20:bframes=3:nocabac:nofast_pskip:frameref=6:subq=6:me=umh:level_idc=31:threads=auto

(these are all widely compatible settings for ps3, xbox 360, appletv, etc.)

Once you get that working, then you can start adding in those other 
options and see if they help or hinder the process. Cabac in particular 
can really help file size and quality, at the expense of being more CPU 
heavy when decoding the video.

I've found that mp4box does a crappy job of extracting the video and 
audio streams. Try this:

Encode as you have been but instead of encoding the audio to aac, encode 
it to pcm.

// extract video
mencoder temp.avi -of rawvideo -nosound -ovc copy -o temp_video.h264
// extract audio
mplayer temp.avi -vc null -vo null -ao pcm:fast
// encode audio
neroaacenc -lc -br 160000 -if audiodump.wav -of temp_audio.m4a
// mux in mp4
mp4box -add temp_video.h264 -add temp_audio.m4a -fps 23.976 -tmp 
/temp/user/1000/ MyMP4.mp4




More information about the MEncoder-users mailing list