Mercurial > mplayer.hg
changeset 17648:5963b50c2178
dwStart support for mencoder.
author | corey |
---|---|
date | Sun, 19 Feb 2006 09:34:37 +0000 |
parents | 1b74cb09e9c1 |
children | a6a8b4287538 |
files | DOCS/man/en/mplayer.1 cfg-mencoder.h help/help_mp-en.h libmpdemux/muxer.h libmpdemux/muxer_avi.c mencoder.c |
diffstat | 6 files changed, 35 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Sun Feb 19 04:31:14 2006 +0000 +++ b/DOCS/man/en/mplayer.1 Sun Feb 19 09:34:37 2006 +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 <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>
--- a/cfg-mencoder.h Sun Feb 19 04:31:14 2006 +0000 +++ b/cfg-mencoder.h Sun Feb 19 09:34:37 2006 +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},
--- a/help/help_mp-en.h Sun Feb 19 04:31:14 2006 +0000 +++ b/help/help_mp-en.h Sun Feb 19 09:34:37 2006 +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"
--- a/libmpdemux/muxer.h Sun Feb 19 04:31:14 2006 +0000 +++ b/libmpdemux/muxer.h Sun Feb 19 09:34:37 2006 +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;
--- a/libmpdemux/muxer_avi.c Sun Feb 19 04:31:14 2006 +0000 +++ b/libmpdemux/muxer_avi.c Sun Feb 19 09:34:37 2006 +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;
--- a/mencoder.c Sun Feb 19 04:31:14 2006 +0000 +++ b/mencoder.c Sun Feb 19 09:34:37 2006 +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)