Opened 22 months ago

Closed 20 months ago

Last modified 20 months ago

#13383 closed Bug Report - General (Fixed)

AVSync2 catch-up problem

Reported by: Peter Bennett Owned by: Peter Bennett
Priority: minor Milestone: 31.0
Component: MythTV - Video Playback Version: v30-fixes
Severity: medium Keywords:
Cc: Ticket locked: no

Description

AVSync2 catch-up of audio sync is not quick enough especially when jumping around a lot.

Attachments (9)

20190201_1637_catchup.patch (1.4 KB) - added by Peter Bennett 21 months ago.
Proposed patch to catch up synchronization faster when off by more than 200 ms
20190204_1416_catchup.patch (1.7 KB) - added by Peter Bennett 21 months ago.
Updated patch that fixes AVSync2 bugs and takes out the audio reset. This should give a better experience, especially in speedup cases.
20190206_1447_catchup.patch (2.1 KB) - added by Peter Bennett 21 months ago.
Next iteration, hopefully the last. Eliminates the judder after a jump and successfully discards excess audio that was causing irritating artifacts. Also works with speedup.
20190207_1442_catchup.patch (2.0 KB) - added by Peter Bennett 21 months ago.
Next attempt - I have changed it to better cater for the case where audio is ahead of video. Pause audio to let video catch up. Also it seems that the drop frame logic was conflicting with the audio adjustment logic so I reinstated the check I had removed.
20190208_1644_catchup_plus.patch (7.2 KB) - added by Peter Bennett 21 months ago.
This adds some suggestions from Mark S: (1) Avsync delta (and GetAudioTime?() should be measured just after wait_for_time() or Show() and saved for next pass, where it is acted upon. (2) remove the test for > 40ms and use the amount specified in AVSyncIncrementMS as the maximum but no minimum.
20190212_1721_catchup_plus_fixed.patch (8.3 KB) - added by Peter Bennett 21 months ago.
New version of patch that fixes LiveTV. When starting live TV there may be a few short pauses while recording catches up with playback, then it will be smooth.
20190213_1544_catchup_plus.patch (10.6 KB) - added by Peter Bennett 21 months ago.
Adds a setting (Setup->Video->Playback->General->Live TV wait. Setting a vaule in there causes a pause for that number of milliseconds when starting Live TV. Also reduce the number of Live TV catch-up messages.
20190214_1507_catchup_plus.patch (11.4 KB) - added by Peter Bennett 21 months ago.
The Live TV Wait is now applied when starting Live TV, changing channels or changing inputs. Also the maximum Live TV wait is now 10 seconds
20190215_1358_liveTV_delay.patch (2.7 KB) - added by Peter Bennett 21 months ago.
Patch for Live TV delay setting.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 21 months ago by Peter Bennett

Other issues:

I have noticed another artifact on the shield with playback of 23.98p fps material at 1.2x on a 4k60hz p display. every second or so you see an old frame where the motion jitters. I suspect this is frame stretching but the page buffer is still flipped

Ive seen another avsync2 artefact (on shield). I was watching a program (1080i 25fps) at 1.2x on 60Hz TV. Smooth playback for 5 secs then about 2 secs of drop every 2nd frame. Note 25*2*1.2 == 60Hz so there must be some synchrony issue.

Changed 21 months ago by Peter Bennett

Attachment: 20190201_1637_catchup.patch added

Proposed patch to catch up synchronization faster when off by more than 200 ms

comment:2 Changed 21 months ago by Peter Bennett

There are a couple of bugs in the AVSync2 code that were not noticed until I tried running it at 2x speed. At 2x speed it goes crazy, accelerating and stopping repeatedly after a jump.

The audio reset I included in this patch is causing some rather weird behavior.

Changed 21 months ago by Peter Bennett

Attachment: 20190204_1416_catchup.patch added

Updated patch that fixes AVSync2 bugs and takes out the audio reset. This should give a better experience, especially in speedup cases.

Changed 21 months ago by Peter Bennett

Attachment: 20190206_1447_catchup.patch added

Next iteration, hopefully the last. Eliminates the judder after a jump and successfully discards excess audio that was causing irritating artifacts. Also works with speedup.

comment:3 Changed 21 months ago by Peter Bennett

Patch number 3 did not work very well. I expect this one to be a big improvement.

Changed 21 months ago by Peter Bennett

Attachment: 20190207_1442_catchup.patch added

Next attempt - I have changed it to better cater for the case where audio is ahead of video. Pause audio to let video catch up. Also it seems that the drop frame logic was conflicting with the audio adjustment logic so I reinstated the check I had removed.

Changed 21 months ago by Peter Bennett

This adds some suggestions from Mark S: (1) Avsync delta (and GetAudioTime?() should be measured just after wait_for_time() or Show() and saved for next pass, where it is acted upon. (2) remove the test for > 40ms and use the amount specified in AVSyncIncrementMS as the maximum but no minimum.

comment:4 Changed 21 months ago by Peter Bennett

With this change, on my system, the audio difference (ms) stays between -5 and +5, instead of between -40 and +40. Will anybody notice the difference?

Changed 21 months ago by Peter Bennett

New version of patch that fixes LiveTV. When starting live TV there may be a few short pauses while recording catches up with playback, then it will be smooth.

comment:5 Changed 21 months ago by Peter Bennett

Status: newaccepted

comment:6 Changed 21 months ago by mspieth

patch 6 looks fine

Changed 21 months ago by Peter Bennett

Adds a setting (Setup->Video->Playback->General->Live TV wait. Setting a vaule in there causes a pause for that number of milliseconds when starting Live TV. Also reduce the number of Live TV catch-up messages.

comment:7 Changed 21 months ago by Peter Bennett

The number of milliseconds delay for Live TV defaults to 0. Setting a value of around 4000 allows Live TV to start without any stuttering. If no value is set, it will catch up but may take a minute or so of occasional stutter.

Changed 21 months ago by Peter Bennett

The Live TV Wait is now applied when starting Live TV, changing channels or changing inputs. Also the maximum Live TV wait is now 10 seconds

comment:8 Changed 21 months ago by Peter Bennett

I have committed a fix 6b402ca5a3b8c45c9ee190aaaf0e63a0d5548855 for avsync2 improvements.

There is a seperate commit 90b4ec347fd01e40f97427de8ab261f74e9b2d68 for LiveTV stutter.

I have not committed the change to add a Live TV delay setting.

Changed 21 months ago by Peter Bennett

Patch for Live TV delay setting.

comment:9 Changed 21 months ago by Peter Bennett

This patch is bad - it fails when changing channels using the program guide. Please disregard it.

comment:10 Changed 20 months ago by Peter Bennett

Resolution: Fixed
Status: acceptedclosed

Base problems are fixed. Live TV delay is not committed as it did not work and is controversial.

comment:11 Changed 20 months ago by Stuart Auchterlonie

Milestone: needs_triage31.0
Note: See TracTickets for help on using tickets.