[MEncoder-users] trouble creating a mp4 file

Grozdan Nikolov (openSUSE Linux) microchip at telenet.be
Tue Jan 22 09:43:07 CET 2008


On Tuesday 22 January 2008 09:14, Alex Samad wrote:
> Hi
>
> I am trying to encode some mpeg src files (from a panasonic video camera)
>
> this is the jist of the script
>
> INFILE="$1"
> OUTFILE="${INFILE/.mpg/}.mp4"
>
> # Passlog
> 	PASSLOG="$WRKDIR/divx2pass.log"
>
> 	# Higher - 1500
> 	# High - 1400 2cd
> 	# Normal ? - 700  1cd
> 	BITRATE=${BITRATE:-1000}
>
>
> 	ENC1="x264 -x264encopts
> subq=4:bframes=4:b_pyramid:weight_b:pass=1:psnr:bitrate=$BITRATE:turbo=1"
> 	ENC2="x264 -x264encopts
> subq=5:partitions=4x4:8x8dct:frameref=3:me=hex:bframes=4:b_pyramid:pass=2:p
>snr:bitrate=$BITRATE"
>
> 	AENC="-af volnorm=1"
>
> 	FILTER1="-vf crop=704:464:6:58"
> 	FILTER1=""
> 	FILTER2="-vf spp,hqdn3d=2:1:2,crop=704:464:6:58"
> 	FILTER2="-vf spp,hqdn3d=2:1:2"
>
> 	# Audio
> 	AUDIO="-oac faac -faacopts object=1:tns:quality=300:mpeg=2"
>
> 	LAMEOPTS="preset=standard"
> 	#LAMEOPTS="br=96:cbr:vol=6"
> 	AUDIOOPT="-lameopts "$LAMEOPTS""
> 	#AUDIO="-oac mp3lame $AUDIOOPT"
>
> 	# Apect ratio input !?
> 	ASPECT="-aspect 16:9"
>
> 	# Additional stuff
> 	ADDOPT="-frames 300"
> 	ADDOPT=
>
>
> 	nice mencoder -quiet \
> 			$ASPECT \
> 			-alang en\
> 			$FILTER1 \
> 			-ovc $ENC1 \
> 			-oac copy \
> 			-passlogfile "$PASSLOG" \
> 			-o /dev/null \
> 			"$INFILE" $ADDOPT
>
> 	nice mencoder -quiet \
> 			$ASPECT \
> 			-alang en\
> 			$FILTER2 \
> 			$AENC \
> 			-ovc $ENC2 \
> 			-passlogfile "$PASSLOG" \
> 			$AUDIO \
> 			-o "$OUTFILE" \
> "$INFILE" $ADDOPT
>
> when I run this again one of the files, I get this with identify
> Playing MOV001.mp4.
> AVI file format detected.
> ID_VIDEO_ID=0
> [aviheader] Video stream found, -vid 0
> ID_AUDIO_ID=1
> [aviheader] Audio stream found, -aid 1
> VIDEO:  [h264]  704x576  24bpp  25.000 fps  998.6 kbps (121.9 kbyte/s)
> Clip info:
>  Software: MEncoder 1.0rc2-4.2.3
> ID_CLIP_INFO_NAME0=Software
> ID_CLIP_INFO_VALUE0=MEncoder 1.0rc2-4.2.3
> ID_CLIP_INFO_N=1
> ID_FILENAME=MOV001.mp4
> ID_DEMUXER=avi
> ID_VIDEO_FORMAT=h264
> ID_VIDEO_BITRATE=998576
> ID_VIDEO_WIDTH=704
> ID_VIDEO_HEIGHT=576
> ID_VIDEO_FPS=25.000
> ID_VIDEO_ASPECT=1.7778
> ID_AUDIO_FORMAT=28781
> ID_AUDIO_BITRATE=274696
> ID_AUDIO_RATE=0
> ID_AUDIO_NCH=0
> ID_LENGTH=73.76
> ==========================================================================
> Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
> Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
> ==========================================================================
> ID_VIDEO_CODEC=ffh264
> ==========================================================================
> Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
> AUDIO: 48000 Hz, 2 ch, s16le, 274.7 kbit/17.88% (ratio: 34337->192000)
> ID_AUDIO_BITRATE=274696
> ID_AUDIO_RATE=48000
> ID_AUDIO_NCH=2
> Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio)
> decoder)
> ==========================================================================
> AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
> ID_AUDIO_CODEC=faad
>
>
> ID_DEMUXER=avi worries me ?

of course it will. you are just changing the file extension of the output file 
to mp4 but mencoder still outputs to avi. You either have to use the lavf 
muxer with mencoder (but forget about using B-Frames with it as it is broken)

-of lavf -lavfopts format=mp4

or you can just encode it to avi and after that use MP4Box to remux this avi 
to the mp4 container, eg

MP4Box -aviraw video file.avi
MP4Box -aviraw audio file.avi

mv *audio.raw audio.aac

MP4Box -add file.h264 -add audio.aac -fps 25 output.mp4 

>
> Also I can't hear any audio when played on a windows box, with media player
> or vlc - I have the ffdshow codecs install

this is probably because you are using AAC Main profile. Try using LC-AAC with 
object=2 in oyur audio settings, eg

-oac faac -faacopts quality=300:object=2:mpeg=4:tns

>
> I remember reading (here I think) that aac + H264 in avi can have problems
> in audio such that only mplayer can play it.  And mplayer plays the output
> okay.
>
> I can work around by using mp3, but I thought I would ask the list first
>
> I will see if I can find a newer version of mencoder as well
>
> Thanks
>
> Alex



More information about the MEncoder-users mailing list