diff options
-rw-r--r-- | DOCS/man/en/mplayer.1 | 19 | ||||
-rw-r--r-- | cfg-mencoder.h | 2 | ||||
-rw-r--r-- | help/help_mp-en.h | 3 | ||||
-rw-r--r-- | libmpdemux/muxer.h | 1 | ||||
-rw-r--r-- | libmpdemux/muxer_avi.c | 13 | ||||
-rw-r--r-- | mencoder.c | 10 |
6 files changed, 35 insertions, 13 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 4624189a77..c2a225c887 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -1098,7 +1098,7 @@ audio delay in seconds (positive or negative float value) .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 @@ colorspace, so it is safe to add it to the configuration file. .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 <any floating-point number> +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> diff --git a/cfg-mencoder.h b/cfg-mencoder.h index b18e904e1e..8cf779a102 100644 --- a/cfg-mencoder.h +++ b/cfg-mencoder.h @@ -221,7 +221,7 @@ m_option_t mencoder_opts[]={ {"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}, diff --git a/help/help_mp-en.h b/help/help_mp-en.h index c7e39db57f..e0eca4121d 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -261,7 +261,8 @@ static char help_text[]= #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" diff --git a/libmpdemux/muxer.h b/libmpdemux/muxer.h index fedbad64f8..ae7882e90c 100644 --- a/libmpdemux/muxer.h +++ b/libmpdemux/muxer.h @@ -59,6 +59,7 @@ typedef struct muxer_t{ 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; diff --git a/libmpdemux/muxer_avi.c b/libmpdemux/muxer_avi.c index 7169a8a4b0..7b3a32413e 100644 --- a/libmpdemux/muxer_avi.c +++ b/libmpdemux/muxer_avi.c @@ -285,6 +285,19 @@ static void avifile_write_header(muxer_t *muxer){ 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; diff --git a/mencoder.c b/mencoder.c index f63fee0d21..167f5567a2 100644 --- a/mencoder.c +++ b/mencoder.c @@ -723,6 +723,8 @@ if(!muxer) { } 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 @@ if ((force_fourcc != NULL) && (strlen(force_fourcc) >= 4)) 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 @@ case ACODEC_COPY: 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 @@ case ACODEC_COPY: 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) |