[MPlayer-dev-eng] accuracy in "-audio-delay"

fresylv2002 at yahoo.it fresylv2002 at yahoo.it
Fri Sep 22 12:25:05 CEST 2006


Hello,
I noticed MEncoder is not very accurate in the option "-audio-delay":

---------------------------------------------
$ mencoder sample.avi -o audio-delay.avi -oac copy -ovc copy -audio-delay 0.1
[...]
Setting audio delay to 0.078s.
[...]

$ mencoder sample.avi -o video-delay.avi -oac copy -ovc copy -audio-delay -0.3
[...]
Setting video delay to 0.267s.
[...]
---------------------------------------------


This can be improved by adding 0.5 to the assignment instructions in the
file libmpdemux/muxer_avi.c (line 287 and following):

---------------------------------------------
  /* 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) {
(1)       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) {
(2)       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);
      }
  }
---------------------------------------------

Examples:

(1)
s->h.dwStart = 0.5 + muxer->audio_delay_fix * s->h.dwRate/s->h.dwScale;

(2)
s->h.dwStart = 0.5 -muxer->audio_delay_fix * s->h.dwRate/s->h.dwScale;


With this simple remedy, we have a greater accuracy:

---------------------------------------------
$ mencoder sample.avi -o audio-delay.avi -oac copy -ovc copy -audio-delay 0.1
[...]
Setting audio delay to 0.104s.
[...]

$ mencoder sample.avi -o video-delay.avi -oac copy -ovc copy -audio-delay -0.3
[...]
Setting video delay to 0.300s.
[...]
---------------------------------------------


Please, can someone fix this?




More information about the MPlayer-dev-eng mailing list