[MPlayer-users] mencoder a-v sync and DVDs (again)

Arpi arpi at thot.banki.hu
Wed Feb 12 21:27:42 CET 2003


Hi,

> So, if I understand you correctly, mencoder and mplayer handle this in
> two different ways:
no

> Mplayer synchonizes audio and video based on the timestamps within each
> stream. At any given point, the positions within each stream may differ
> relative to the start of the stream.
yes

> Mencoder muxes audio and video from the beginning of each stream. Each
> stream's position relative to its beginning is always the same.
no!

the same a-v sync method is used in both.

mplayer:

      AV_delay=(a_pts-delay-audio_delay)-v_pts;
      if(drop_frame_cnt>50+drop_message*250 && AV_delay>0.5){
        ++drop_message;
        mp_msg(MSGT_AVSYNC,MSGL_ERR,MSGTR_SystemTooSlow);
      }
      x=AV_delay*0.1f;
      if(x<-max_pts_correction) x=-max_pts_correction; else
      if(x> max_pts_correction) x= max_pts_correction;
      if(default_max_pts_correction>=0)
        max_pts_correction=default_max_pts_correction;
      else
        max_pts_correction=sh_video->frametime*0.10; // +-10% of time
      if(!frame_time_remaining){ sh_audio->delay+=x; c_total+=x;} //correction

mencoder:

    AV_delay=(a_pts-v_pts);
    AV_delay-=mux_a->timer-(mux_v->timer-(v_timer_corr+v_pts_corr));
        // compensate input video timer by av:
        x=AV_delay*0.1f;
        if(x<-max_pts_correction) x=-max_pts_correction; else
        if(x> max_pts_correction) x= max_pts_correction;
        if(default_max_pts_correction>=0)
          max_pts_correction=default_max_pts_correction;
        else
          max_pts_correction=sh_video->frametime*0.10; // +-10% of time
        // sh_video->timer-=x;
        c_total+=x;
        v_pts_corr+=x;


the difference is that mplayer compensates A-V by teh audio card's buffering
delay, while mencoder doe sthe compensation of muxer's delay (preload).

i can imagine that the <100ms delay comes from the audio codecs, probably
from libmp3lame's buffering, especialy in VBR modes.
there are ~38 audio frames for 1 sec, it means ~26ms/frame, so if it buffers
up a few frames it may cause some delay.

try encoding using -oac pcm, or -oac copy and check if the delay still exists.
maybe i have to hack it a bit to compensate codec's (encoder) delay.

also, it's possible that video encoder delays 1 frame, if using B frames.
try -ovc rawrgb, if it solves a-v issue then it's the problem.


A'rpi / Astral & ESP-team

--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu
    "However, many people beg for its inclusion in Debian. Why?" - Gabucino
  "Because having new software in Debian is good." - Josselin Mouette
"Because having good software in Debian is new." - Gabucino



More information about the MPlayer-users mailing list