[MPlayer-users] A/V sync problem when appending AVIs
danny
guru at digitalfantasy.it
Mon Feb 9 11:28:11 CET 2004
Alle 09:18, venerdì 6 febbraio 2004, Daniele Forghieri ha scritto:
> Matthias Czapla wrote:
> >Hello!
> >
> >I have created three AVI files with (for each one)
...
> mp3 uses packet of sound of, say, 250 millisec.
>
> In any file you have a certain number of complete packet.
>
> If the length of the video file is not exactly a multiple of the packet
> size (in millisec) you' ve got an A/V desync in the second (and
> successive) files.
>
> At the end of the mencoder encode you got something like
> video: 120.040 sec, 2401 frames
> audio: 120.250 sec
>
> and the sound 'drift' is 210 millisec.
>
> To avoid the problem I encode the audio in PCM and, after you cat the
> files, convert in mp3
>
> Daniele Forghieri
>
> _______________________________________________
> MPlayer-users mailing list
> MPlayer-users at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-users
I take a deeper look at this.
The mp3 packed is composed of 1152 samples (the tmp[2304] in mencoder source
should give me an hint ...).
At 44100 hz is 1152/44100 -> 26.122 millisec, at 48000 hz is 24 millisec, so
it is irrilevant.
I make a test with an avi file of 5 minutes splitted in 5 parts of about 1
minute each with pcm audio.
if I use mp3lame i obtain this result (the video are of differrent len because
i split on a keyframe)
video frames audio
60.040 1501 60.552
60.320 1508 60.840
59.640 1491 60.144
60.000 1500 60.504
60.000 1500 60.504
-------- ------- --------
300.000 7500 302.544
If i cat this file i obtain an A/V desync, very notable.
I try also using the mp3 encoder of lavc (-oac lavc -lavcopts
acodec=mp3:abitrate=128) and the result are:
video frames audio
60.040 1501 59.976 ( - 0.064)
60.320 1508 60.264 ( - 0.056)
59.640 1491 59.592 ( - 0.048)
60.000 1500 59.952 ( - 0.048)
60.000 1500 59.952 ( - 0.048)
-------- ------- --------
300.000 7500 299.736
Here some frames (2) are missed. The desync is less notable.
If i convert every avi in pcm i obtain the same video and audio size so no a/v
desync but ....
if i use pcm sound and i use -endpos to cut the end of the files i obtain that
the audio is at least 0.5 second longer than the video so, if i join the avi,
i obtain on the last piece of video a 2.5 second of delay (and not 2.0 as i
expected!)
To summarize: mencoder puts on the avi file more audio than needed. There is
no problem if you watch the avi (the audio in the end of the file and you
don't have any desync) but is a problem if you simply cat the avi to merge
them.
A solution is to modifiy mencoder to output exactly the audio needed to match
the video (with an option?) or build a program that read the avi and, at the
end,. ignores the extra audio data.
Daniele Forghieri
More information about the MPlayer-users
mailing list