[mythtv] AVSync in master, Normal decoding, vga monitor and built-in audio analog stereo

Mark Kendall mark.kendall at gmail.com
Tue Dec 10 11:09:34 UTC 2019


On Tue, 10 Dec 2019 at 10:07, John Pilkington <johnpilk222 at gmail.com> wrote:
> Hi Mark:  As I said in my reply to Gregorio's post,
>
> > I have increased the AVSync2 increment to 4 ms and selected the low quality deinterlace options, and the drift does seem to have gone away.
>
> The root cause seems to be a systematic and cumulative difference
> between what is being controlled and what ought to be being controlled,
> and if the suggested new 'loop gain' approach works with the timestamps
> as they actually reach the hardware that ought to improve things.
>
> Testing of options is slow because the effects are slow to appear, and
> I'm not sure what to try now.
>
> I should make clear that I don't expect my windowed displays on monitors
> to deliver the greatest AV experience.  They're just tools in the chain.

John

Trying to join the dots on what may be happening.

Based on feedback from yourself and Gregorio, it looks like the issue
lies with the FFmpeg medium and high quality deinterlacers (yadif and
bwdif respectively).

Revisiting the mythtv code, we do not feed any timestamps into the
ffmpeg deinterlacing filters or use any timestamps that may be
returned. I *think* timestamps and hence the a/v sync code are
irrelevant.

What *may* be happening is that the deinterlacers are somehow not
dealing with discontinuities when a frame is dropped. Hence, for
whatever reason, the actual video frame returned does not physically
match the frame originally associated with the video timestamp. A
small difference is expected due to buffering in the filter (and there
is a todo on the render branch wiki page about handling that
difference). But what I believe you are seeing is the cumulative
effect over time of multiple frame drops. In your case, this is
exacerbated by the fact that it appears you are running at a very high
system load during playback (which will be partly due to the
deinterlacers themselves) and hence dropping frames regularly.

The solution may be to flush the deinterlacing filters when a
discontinuity is detected (i.e. a frame is dropped) - but that may
have a knock on effect on the quality of playback.

It may also be appropriate to explicitly pass the video timestamps
into the filter so it is itself aware of discontinuities - but my
understanding of the libavfilter internals is limited - so don't know
whether this would help.

What I will do is add some logging to the software deinterlacers to
show when a frame is not returned as expected - which should indicate
if/when it starts to run out of sync.

Regards
Mark


More information about the mythtv-dev mailing list