diff -ur main.orig/libmpdemux/demux_avi.c main.patchtest/libmpdemux/demux_avi.c --- main.orig/libmpdemux/demux_avi.c 2006-02-16 18:09:41.000000000 -0800 +++ main.patchtest/libmpdemux/demux_avi.c 2006-02-16 18:59:32.000000000 -0800 @@ -612,6 +612,12 @@ mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%d (%u) audio size=%d\n",vsize,priv->numberofframes,asize); sh_video->i_bps=(float)vsize/(sh_video->frametime*priv->numberofframes); } + + if (sh_video) + sh_video->stream_delay = (float)sh_video->video.dwStart * sh_video->video.dwScale/sh_video->video.dwRate; + if (sh_audio) + sh_audio->stream_delay = (float)sh_audio->audio.dwStart * sh_audio->audio.dwScale/sh_audio->audio.dwRate; + return demuxer; } diff -ur main.orig/libmpdemux/stheader.h main.patchtest/libmpdemux/stheader.h --- main.orig/libmpdemux/stheader.h 2006-02-13 12:55:43.000000000 -0800 +++ main.patchtest/libmpdemux/stheader.h 2006-02-16 18:59:32.000000000 -0800 @@ -12,6 +12,7 @@ unsigned int format; int inited; float delay; // relative (to sh_video->timer) time in audio stream + float stream_delay; // number of seconds stream should be delayed (according to dwStart or similar) // output format: int sample_format; int samplerate; @@ -54,6 +55,7 @@ unsigned int format; int inited; float timer; // absolute time in video stream, since last start/seek + float stream_delay; // number of seconds stream should be delayed (according to dwStart or similar) // frame counters: float num_frames; // number of frames played int num_frames_decoded; // number of frames decoded diff -ur main.orig/mplayer.c main.patchtest/mplayer.c --- main.orig/mplayer.c 2006-02-16 18:09:41.000000000 -0800 +++ main.patchtest/mplayer.c 2006-02-16 18:59:32.000000000 -0800 @@ -2522,8 +2522,14 @@ current_module="av_init"; -if(sh_video) sh_video->timer=0; -if(sh_audio) sh_audio->delay=-audio_delay; +if(sh_video){ + sh_video->timer=0; + audio_delay += sh_video->stream_delay; +} +if(sh_audio){ + audio_delay -= sh_audio->stream_delay; + sh_audio->delay=-audio_delay; +} if(!sh_audio){ mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound);