? libmpdemux/.muxer.h.swp Index: cfg-mencoder.h =================================================================== RCS file: /cvsroot/mplayer/main/cfg-mencoder.h,v retrieving revision 1.106 diff -u -r1.106 cfg-mencoder.h --- cfg-mencoder.h 9 Jan 2006 19:35:43 -0000 1.106 +++ cfg-mencoder.h 18 Feb 2006 22:19:46 -0000 @@ -221,7 +221,7 @@ {"audio-density", &audio_density, CONF_TYPE_INT, CONF_RANGE|CONF_GLOBAL, 1, 50, NULL}, {"audio-preload", &audio_preload, CONF_TYPE_FLOAT, CONF_RANGE|CONF_GLOBAL, 0, 2, NULL}, - {"audio-delay", &audio_delay_fix, CONF_TYPE_FLOAT, CONF_MIN|CONF_GLOBAL, 0, 0, NULL}, + {"audio-delay", &audio_delay_fix, CONF_TYPE_FLOAT, CONF_GLOBAL, 0, 0, NULL}, {"x", "-x is obsolete, use -vf scale=w:h for scaling.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, {"xsize", "-xsize is obsolete, use -vf crop=w:h:x:y for cropping.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, Index: mencoder.c =================================================================== RCS file: /cvsroot/mplayer/main/mencoder.c,v retrieving revision 1.337 diff -u -r1.337 mencoder.c --- mencoder.c 17 Feb 2006 01:57:40 -0000 1.337 +++ mencoder.c 18 Feb 2006 22:19:47 -0000 @@ -723,6 +723,8 @@ } if(out_file_format == MUXER_TYPE_MPEG) audio_preload = 0; +muxer->audio_delay_fix = audio_delay_fix; + // ============= VIDEO =============== mux_v=muxer_new_stream(muxer,MUXER_TYPE_VIDEO); @@ -864,6 +866,8 @@ mux_v->bih->biCompression, (char *)&mux_v->bih->biCompression); } + muxer->audio_delay_fix -= sh_video->stream_delay; + //if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf! // ============= AUDIO =============== @@ -942,7 +946,6 @@ mux_a->h.dwSampleSize=sh_audio->audio.dwSampleSize; mux_a->h.dwScale=sh_audio->audio.dwScale; mux_a->h.dwRate=sh_audio->audio.dwRate; -// mux_a->h.dwStart=sh_audio->audio.dwStart; } else { mux_a->h.dwSampleSize=mux_a->wf->nBlockAlign; mux_a->h.dwScale=mux_a->h.dwSampleSize; @@ -958,10 +961,7 @@ if (verbose>1) print_wave_header(mux_a->wf); -if(audio_delay_fix!=0.0){ - mux_a->h.dwStart=audio_delay_fix*mux_a->h.dwRate/mux_a->h.dwScale; - mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_SettingAudioDelay,mux_a->h.dwStart*mux_a->h.dwScale/(float)mux_a->h.dwRate); -} + muxer->audio_delay_fix += sh_audio->stream_delay; } // if(sh_audio) Index: DOCS/man/en/mplayer.1 =================================================================== RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v retrieving revision 1.1227 diff -u -r1.1227 mplayer.1 --- DOCS/man/en/mplayer.1 13 Feb 2006 11:15:24 -0000 1.1227 +++ DOCS/man/en/mplayer.1 18 Feb 2006 22:19:50 -0000 @@ -1098,7 +1098,7 @@ .br .I NOTE: When used with MEncoder, this is not guaranteed to work correctly -with \-ovc copy. +with \-ovc copy; use \-audio-delay instead. . .TP .B \-demuxer <[+]name> @@ -6058,11 +6058,18 @@ .SH "GENERAL ENCODING OPTIONS (MENCODER ONLY)" . .TP -.B \-audio-delay <0.0\-...> -Sets the audio delay field in the header. -Default is 0.0, negative values do not work. -This does not delay the audio while encoding, but the player will see the -default audio delay, sparing you the use of the \-delay option. +.B \-audio-delay +Delays either audio or video by setting a delay field in the header +(default: 0.0). +This does not delay either stream while encoding, but the player will +see the delay field and compensate accordingly. +Positive values delay the audio, and negative values delay the video. +Note that this is the exact opposite of the \-delay option. +For example, if a video plays correctly with \-delay 0.2, you can +fix the video with MEncoder by using \-audio-delay -0.2. +.sp 1 +Currently, this option only works with the default muxer (\-of avi). +If you are using a different muxer, then you must use \-delay instead. . .TP .B \-audio-density <1\-50> Index: help/help_mp-en.h =================================================================== RCS file: /cvsroot/mplayer/main/help/help_mp-en.h,v retrieving revision 1.221 diff -u -r1.221 help_mp-en.h --- help/help_mp-en.h 30 Jan 2006 19:37:17 -0000 1.221 +++ help/help_mp-en.h 18 Feb 2006 22:19:50 -0000 @@ -261,7 +261,8 @@ #define MSGTR_CBRPCMAudioSelected "CBR PCM audio selected\n" #define MSGTR_MP3AudioSelected "MP3 audio selected\n" #define MSGTR_CannotAllocateBytes "Couldn't allocate %d bytes\n" -#define MSGTR_SettingAudioDelay "Setting AUDIO DELAY to %5.3f\n" +#define MSGTR_SettingAudioDelay "Setting audio delay to %5.3fs\n" +#define MSGTR_SettingVideoDelay "Setting video delay to %5.3fs\n" #define MSGTR_SettingAudioInputGain "Setting audio input gain to %f\n" #define MSGTR_LamePresetEquals "\npreset=%s\n\n" #define MSGTR_LimitingAudioPreload "Limiting audio preload to 0.4s\n" Index: libmpdemux/muxer.h =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.h,v retrieving revision 1.18 diff -u -r1.18 muxer.h --- libmpdemux/muxer.h 26 Jan 2006 19:32:07 -0000 1.18 +++ libmpdemux/muxer.h 18 Feb 2006 22:19:50 -0000 @@ -59,6 +59,7 @@ off_t movi_start; off_t movi_end; off_t file_end; // for MPEG it's system timestamp in 1/90000 s + float audio_delay_fix; // index: AVIINDEXENTRY *idx; int idx_pos; Index: libmpdemux/muxer_avi.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_avi.c,v retrieving revision 1.35 diff -u -r1.35 muxer_avi.c --- libmpdemux/muxer_avi.c 26 Jan 2006 19:32:07 -0000 1.35 +++ libmpdemux/muxer_avi.c 18 Feb 2006 22:19:50 -0000 @@ -285,6 +285,19 @@ mp_msg(MSGT_MUXER, MSGL_INFO, "ODML: vprp aspect is %d:%d.\n", aspect >> 16, aspect & 0xffff); } + /* deal with stream delays */ + for (i = 0; muxer->streams[i] && i < MUXER_MAX_STREAMS; ++i) { + muxer_stream_t *s = muxer->streams[i]; + if (s->type == MUXER_TYPE_AUDIO && muxer->audio_delay_fix > 0.0) { + s->h.dwStart = muxer->audio_delay_fix * s->h.dwRate/s->h.dwScale; + mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_SettingAudioDelay, (float)s->h.dwStart * s->h.dwScale/s->h.dwRate); + } + if (s->type == MUXER_TYPE_VIDEO && muxer->audio_delay_fix < 0.0) { + s->h.dwStart = -muxer->audio_delay_fix * s->h.dwRate/s->h.dwScale; + mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_SettingVideoDelay, (float)s->h.dwStart * s->h.dwScale/s->h.dwRate); + } + } + if (isodml) { unsigned int rifflen, movilen; int i;