[mythtv] AV-Sync problem

David Wong david.wong at marvel.com.hk
Fri Apr 24 03:52:43 UTC 2009

----- "Ed W" <lists at wildgooses.com> wrote:
> David Wong wrote:
> > I tried MythTV standard decoder and xv-blit renderer.
> > It hits a longer time before audio buffer starting to underrun.
> >
> > I further look into the stream using my home-brew TS demuxer.
> > Video and Audio PES packets are almost 2 seconds apart
> >
> > See attached log.
> > PID 141 is video, PID 142 is audio
> > PTS rate should be 90000 per second.
> >
> > I checked the libmythtv code. It seems directly sending audio data
> to buffer via AddAudioData(),
> > whenever avformatdecoder hit an audio frame. But video has it own
> output thread and queue.
> > I have perception that with this architecture, the AV-Sync is very
> rely on the tight distance
> > between video and audio packet.
> >
> > It is better that both Video and Audio have their own output
> buffer,
> > each data chunk entry in each buffer should associated with time
> stamp.
> > Video and audio are then sent out when time reached.
> > At start of clip, there may be video without corresponding audio.
> > Then just send out video first and then start to send out audio when
> at 
> > appropriate time.
> >   
> I *think* this is an issue I see on UK DVB on any black scenes - I
> had
> presumed that the gap between video and audio was getting too large
> (but
> still acceptable).  I haven't had a chance to debug this in any
> detail
> though
> Also have you checked that it's not the audio buffer which is
> overflowing rather than the video?  I think the choppiness may be due
> to
> the lag in refilling the audio buffer once it's decided that it's
> desynced - ie it's a bit circular and one effect drives the other?
> Good luck
> Ed W
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

I think it is audio buffer being under-run.
I see lots of audio buffer under run warnings from the debug log.

I checked the PTS of Audio PES and Video PES packets, using my home-brew TS demux code.
The audio and video are nearly 2 seconds apart.

I tried svn trunk, it is improved a bit. It is ok if play back from recorded video.
But it has problem when play from "Watch TV". Audio doesn't under run,
but some video frame displayed in wrong time / wrong order.

If using 0.21 branch, even using standard decoder and xv renderer, audio still being under-run.


More information about the mythtv-dev mailing list