[mythtv] AV-Sync problem

David Wong david.wong at marvel.com.hk
Sat Apr 18 03:07:16 UTC 2009


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.

David 

----- Original Message -----
From: "David Wong" <david.wong at marvel.com.hk>
To: mythtv-dev at mythtv.org
Sent: Tuesday, April 14, 2009 5:01:50 PM (GMT+0800) Asia/Hong_Kong
Subject: AV-Sync problem

Hi all, 

I am running 0.21 branch with VDPAU patch #r20300, on NVidia 9400 IGP with Intel Q2D E7400 2.8GHz.

When I play some of DTV channel in my living place, I got lots of following warnings: 

"Audio 686 ms behind video but already 75 video frames queued. AV-Sync might be broken. "

and some audio buffer underrun error, both video and audio are not smooth.
Video output resolution is not important too.

It only happens in 2 SD H.264 channels from same broadcaster here. 

It looks like that audio packet, in form of libavformat packet?, is very lag behind video.
It is not very surprising as the two channels are rather low bit rate. Broadcaster makes very extreme
 configuration to accommodate 1 HD and 3 SD channels in a 21Mbps carrier. 

I check into the code. It seems the playback engine only checks enough video when pre-buffering,
 and left audio buffer unchecked. Is my observation valid? Are there anyway to both ensure enough
 video and audio before playback?

Or anyway to buffer more data? I think it is better to be measured in time rather than in data size.

Regards,
David.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ch14_output.txt
URL: <http://mythtv.org/pipermail/mythtv-dev/attachments/20090418/a54adec1/attachment.txt>


More information about the mythtv-dev mailing list