[MEncoder-users] number of yuv4mpeg frames does not match audio length

Henk Schoneveld belcampo at zonnet.nl
Thu May 22 20:28:22 CEST 2008


> I am trying to convert a VOB file to h264+aac in an mp4 container (using
> x264, faac and MP4Box). I don't get the mp4 to be A/V sync (the
> material has some very obvious points). Investigating this problem, I
> found that the yuv4mpeg stream that I am using as input for x264 does
> not have the expected number of frames. As a reference, I look at the
> duration of the extracted audio:
>
> mplayer -vo null -ao pcm test.vob
>
> Duration    : 00:00:11.168
>
> At my framerate of 29.97, this corresponds with 334.7 frames (not sure 
> whether to round this up or truncate it)
Frames do come in a GroupOfPictures. In PAL 25fps it starts with a 
I-Frame or named keyframe till the next I-frame wich is 0.48 seconds 
later. Every frame is (1 sec / 25 fps) = 0.04 sec. So every 12th is the 
start of a new GOP.
The length of a sound-frame depends on the Samplerate, sampled at 44100, 
the framelength is half of sound sampled at 22050. So frame length of 
video and audio differ they will be exactly the same only every now and 
then. As an example in PAL DVB with sound sampled at 48000 it will be 
every 1.2 sec.
Try this for example:
ffmpeg -i test.vob x264params -f rawvideo test.h264
ffmpeg -i test.vob faacparams -f rawvideo test.aac
MP4Box -add test.h264 -add test.aac test.mp4
If you don't get prefect sync you can resolve this afterwards with
MP4Box -delay 1=200 test.mp4
if sound would be delayed by 200ms

Henk Schoneveld
>
> However this is what I get with mplayer, mencoder and ffmpeg. ffmpeg
> gives by far the strangest output.
>
> mplayer -harddup -noframedrop -vo yuv4mpeg -ao null test.vob
>
>   333 frames
>
> mencoder test.vob -vf-add harddup -vf-add =i420 -ovc raw -of rawvideo 
> -nosound -o mencoder.420
>
>   333 frames
>
> ffmpeg -i test.vob -f yuv4mpegpipe ffmpeg.yuv
>
>   342 frames (starting with 1 totally green frame)
>
> Especially the ffmpeg output is quite surprising. I guess the 
> mplayer/mencoder
> output could be correct, and the sync problem is elsewhere, though 
> this still
> doesn't account for the missing frame...
>
> Any advice would be greatly appreciated!
>
> Maarten





More information about the MEncoder-users mailing list