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

Corey Hickey bugfood-ml at fatooh.org
Tue Jan 31 05:17:05 CET 2006


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'.

Now, play delay10.avi with mplayer. Unless I'm mixed up, you won't
notice any difference in the A-V sync, even though the audio should now
be 10 seconds behind the video. I tested a few other video players:

ffplay:                no difference
vlc:                   no difference
Media Player Classic:  no difference
Windows Media Player:  plays video for 10 seconds, then starts audio

Normally speaking I would call something done only by Windows Media
Player a bug :) ...but in this case I think it's actually the correct
behavior. A couple docs:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedshow/html/_dxce_dshow_avi_stream_headers.asp
http://virtualdub.com/blog/pivot/entry.php?id=27


MPlayer is reading dwStart from the stream header correctly:
====== STREAM Header =====
Type: auds   FCC: U (55)
Flags: 0
Priority: 0   Language: 0
InitialFrames: 0
Rate: 48000/1152 = 41.667
Start: 416   Len: 9081    <---- The "Start" here, in number of samples
Suggested BufferSize: 960
Quality 0
Sample size: 0
==========================

I can only find one references to dwStart in the demuxer code; it's in
demux_avi.c, demux_seek_avi(), line 711. Here are a few lines around
that one:

----------
curr_audio_pos=(priv->avi_video_pts)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale;
curr_audio_pos-=sh_audio->audio.dwStart;
curr_audio_pos*=sh_audio->audio.dwSampleSize;
----------

So, it looks as if the AVI demuxer tries to adjust, but it doesn't have
the right effect. At this point I don't know how to fix it; the demuxer
code is still mostly opaque to me. Does anyone have any pointers?

-Corey




More information about the MPlayer-dev-eng mailing list