[MEncoder-users] Remuxing to mp4 on windows

James Hastings-Trew jimht at shaw.ca
Tue May 27 20:28:31 CEST 2008


This is a followup to a previous discussion. To generate an .mp4 file 
with b-frames, the general recipe has been to encode the audio and video 
into an AVI file, and then extract the aac and .h264 streams and remux 
them with mp4box. I reported that for a variety of reasons, this wasn't 
working for me. Specifically, I found a 4Gb file size limit for files 
handled by mp4box, and and problems with the .aac files produced by 
mencoder, or playback problems with Quicktime. The method that failed 
for me looked something like this:
> mencoder $input -o NUL -sws 9 -vf harddup -oac copy -ovc x264 
> -x264encopts 
> bitrate=3400:vbv_maxrate=7000:vbv_bufsize=1200:bframes=3:nocabac:frameref=1:subq=1:level_idc=31:threads=auto:pass=1:turbo
>
> mencoder $input -o temp.avi -of avi -noodml -sws 9 -vf  harddup -oac 
> faac -faacopts br=160:object=2 -channels 2 -srate 48000 -ovc x264 
> -x264encopts 
> bitrate=3400:vbv_maxrate=7000:vbv_bufsize=1200:bframes=3:partitions=all:me=umh:nocabac:frameref=6:subq=6:level_idc=31:threads=auto:pass=2
>
> mp4box -aviraw video temp.avi
> mp4box -aviraw audio temp.avi
> rename temp_audio.raw temp_audio.aac
> mp4box -add temp_video.h264 -add temp_audio.aac -fps 23.976 -tmp c:\temp 
> MyMP4.mp4
>   
I found that this alternative method works much better, and eliminates 
all of the problems I was having:

encode video and audio to AVI with pcm audio (-oac pcm -channels 2 
-srate 48000)
extract video stream:
    mencoder temp.avi -of rawvideo -nosound -ovc copy -o temp_video.h264
extract audio stream:
    mplayer temp.avi -vc null -vo null -ao pcm:fast
encode audio stream to aac:
    neroaacenc -lc -br 1600000 -if audiotemp.wav -of temp_audio.m4a
mux to mp4:
    mp4box -add temp_video.h264 -add temp_audio.m4a -fps 23.976 -tmp 
c:\temp MyMP4.mp4

Mp4box does not seem to have a 4Gb limit on muxing, but definitely has 
one on extracting streams from large AVI files.

Resulting file plays well in everything I have tested it with, and audio 
sync is maintained. Hope this helps someone.




More information about the MEncoder-users mailing list