[mythtv] AVSync2 Improvements

David Engel david at istwok.net
Fri Feb 15 03:08:25 UTC 2019


Note there is a serious, new regression with the 0214 patch described
at the end.

On Thu, Feb 14, 2019 at 07:00:43PM -0500, Peter Bennett wrote:
> 
> 
> On 2/14/19 6:05 PM, Mark Kendall wrote:
> > Peter,
> > 
> > This discussion and the direction the code is going worries me.
> > 
> > Firstly, as I've said recently, I never took any interest in the a/v
> > sync code before because it just worked. It might have a jitter or two
> > after a seek, channel change etc - but it always recovered.
> > Over the last few weeks I've realised that just isn't the case any
> > more - for 'old' avsync  or avsync2. Both just get it wrong far too
> > often and in the worst cases never recover and/or

I've been happy with avsync2 (before the recent patches) *after* it's
synced.  Using the actual timestamps for the audio and video seems
like the right answer.  Using frame drop prediction works in many
cases but breaks down when there are variable frame rates.

You're right, though, that old avsync did well enough in the worst
cases like starting playback/live TV, skipping and changing channels.
That's why I asked for improvements in those areas.


> just lose the plot
> > suddenly when playback has been fine and uninterrupted for minutes
> > beforehand.
> I have never noticed that - see the comment about Music Choice below.

I have seen some cases of that but didn't bring them up because I
ddin't associate them with avsync2.

> > As far as I'm concerned this is a regression.
> Please make sure you do not have the setting "Music Choice" checked. This
> may cause out of sync playback, so preferably leave it turned off if
> possible.
> 
> > Secondly and more importantly, I think you're fighting symptoms and
> > not causes. I think David alluded too it in a previous email - but
> > fundamentally the code is starting to control a/v sync after the
> > battle has been lost. Audio and video are taking very different paths
> > after being demuxed - and in the most common case, the far longer path
> > is for video. I think you need to look at how playback is
> > started/restarted and ensure that, for example, the audio doesn't
> > start playing 20-30 frames ahead of the video (seen commonly here). It
> > is so obvious sometimes that the playback window is still showing when
> > the audio has started.

To my naive mind, do something like this:

    wait until you've got at least one audio and video frame each.

    if audio is ahead of video, thow away audio as it comes in until
    its timestamp is the same or close enough to the first video
    timestamp.
    
    if video is ahead of audio, thow away video as it comes in until
    its timestamp is the same or close enough to the first audio
    timestamp.

    wait until enough audio and video has been decoded and start
    playback.

I don't know the av code well enough to know if this is feasible or
would even work.

> > If that can be addressed, then the job of the main a/v sync code
> > becomes much easier - and the complexity that seems to be being
> > introduced can be avoided.
> Have you tried the latest patch? AVSync2 was designed to be smoother but it
> was unfortunately taking a few seconds to get audio and video synchronized
> at the start. The latest patch is primarily to address that. It also
> addresses the problem of audio starting too soon.
> > I would definitely suggest that adding a setting to work around a
> > semi-random/uncontrollable delay is a bad idea.
> David requested that. It defaults to zero. See if you can convince him :).

It was requested as a stopgap until a better solution could be found.
I'm a big proponent that things like this should work well in the
majority of cases without any configuration needed.

Here's the new, serious regression.  Choose a theme with a video
window in the EPG (Blue Abstract should work).  Set live TV wait to
1000ms (that's what I used).  Start live TV.  Bring up the EPG and use
it to change channels.  Video playback continues in the small window
and never switches back to full screen.

David
-- 
David Engel
david at istwok.net


More information about the mythtv-dev mailing list