[MPlayer-dev-eng] dwStart (stream delay in AVI files)

Corey Hickey bugfood-ml at fatooh.org
Tue Jan 31 09:51:49 CET 2006


Michael Niedermayer wrote:
>>>>I _think_ mplayer doesn't properly use the dwStart field in the stream
>>>>header of AVI files. To reproduce, create a file with 10-second audio delay:
>>>>
>>>>mencoder file.avi -ovc copy -oac copy -audio-delay 10 -o delay10.avi
>>>>
>>>>MEncoder writes the audio delay in the dwStart field of the audio
>>>>stream. You can check it with a hex editor or with 'mplayer -v delay10.avi'.
>>>
>>>
>>>MEncoder supports -delay now anyway, you should use that... -audio-delay is 
>>>a hack..
>>
>>Are you sure? That seems to be the intended purpose of dwStart,
>>especially considering that Microsoft's player appears to use it that
>>way and -audio-delay is the documented way to adjust A-V sync with
>>mencoder.
>>
>>Up to this moment I was thinking of using dwStart to compensate for
>>video decoding delay (with B-frames), but then I realized it could be
>>detrimental to remuxing to other containers.
> 
> 
> which? avi supports dwStart, nut can start at any timestamp too, mpeg-ps/ts
> is fine too, basically a container which requires that the first packet of
> every stream has the absolutly identical pts is quite limited

Right, but the approach I was considering was to use dwStart to make a
video player play the audio stream with a slight delay, thus matching it
up to the slightly-delayed video frames. Remuxing to a container that
uses pts would result in the video frames being played back without
delay and the dwStart-induced audio delay would be erroneous.

Here are simplified playback timing tables of what I'm thinking will
happen from using dwStart like that. The numbers

original   decoding   dwStart-   remuxed
file       delay      adjusted   with PTS
-----------------------------------------
A1  V1     A1                        V1
A2  V2     A2  V1     A1  V1     A1  V2
A3  V3     A3  V2     A2  V2     A2  V3
A4  V4     A4  V3     A3  V3     A3  V4
               V4     A4  V4     A4


Of course, if the remuxing program ignored dwStart, that wouldn't be a
problem; however, ignoring dwStart would break the remuxing of files
that actually do have a valid delay in either of the streams.

>>Nevertheless, it still seems to me that supporting dwStart in mplayer
>>would be a good thing.
> 
> yes, and yes ff* ignores it as i couldnt find a file which needed it
> maybe you could make yours available?

I'm not sure if I've found one in the wild; it could be that some files
which I thought were very poorly-encoded actually used dwStart and I
didn't know it. Anyway, you can create such a file with the command at
the top of this email, or get mine from here:

http://fatooh.org/files/tmp/delay10.avi

Short version, smaller download:

http://fatooh.org/files/tmp/delay10-short.avi

-Corey




More information about the MPlayer-dev-eng mailing list