mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 06:03:45 +01:00
dwStart support for mencoder.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17649 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
0d29a779f8
commit
89d848a8a2
@ -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>
|
||||
|
@ -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},
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
10
mencoder.c
10
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user