xbmc icon indicating copy to clipboard operation
xbmc copied to clipboard

Sync issue - video progressively lags further behind audio with low resolution media

Open andrewgreenwood opened this issue 6 years ago • 12 comments

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

Lower-resolution videos suffer from lag on Raspberry Pi, with the video progressively getting delayed further behind the audio. It begins very quickly (noticeable within a minute of beginning playback).

I first noticed this with SDTV (704x576) content being streamed from PVR, however the problem is not isolated to the PVR functionality as it occurs with other low-resolution videos in my media library (I tried one that was 368x272). HD content is not affected at all.

If I bring up the on-screen controls and press pause, then play, it will be in-sync for another minute or so, and I have to repeat this throughout playback. Pressing the "back" button on my TV remote control brings up the main Kodi UI which causes the video to return to being in-sync with the audio (again, for a minute or so.)

As I mostly play HD content I am not entirely sure when this first started. I first noticed it in RC1 but the problem remains as of a fresh build of LibreELEC yesterday.

This only appears to happen on Raspberry Pi. I have been running RC2 on my Windows PC, which does not suffer the problem.

I have tried enabling (separately) "Adjust display refresh rate", "Sync playback to display" and also enabling/disabling the OMX Player to see if that made any difference, but the results are the same.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

Video playback should be in-sync with audio throughout playback.

Actual Behavior

Video lags behind audio after a minute or so by a noticeable amount.

To Reproduce

Steps to reproduce the behavior: On a Raspberry Pi:

  1. Play a low-resolution video for a couple of minutes
  2. After a minute, the audio and video will drift out of sync
  3. Press the "back" button to bring up the Kodi UI, notice that the video in the background will be back in-sync with audio

Debuglog

The debuglog can be found here: https://paste.kodi.tv/wijezehoto.kodi

Screenshots

Here are some links or screenshots to help explain the problem:

I recorded a video with my phone: http://misc.greenwoodprojects.net/kodi_lag.mp4

The start of the video corresponds approximately to 23:00:36 in the log file (the first button press is "select" which is one second into the video).

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

I notice throughout playback that there are many log entries of this nature: 23:00:53.026 T:1914913648 DEBUG: ActiveAE::SyncStream pll:0.00000 (act:1.00000 lim:0.00000) rr:1.00036 threshold:0.020 error:0.719960

Upon pressing the back button on my remote control to open the main Kodi UI during playback, I see a number of log entries relating to OMX.broadcom which coincide with the video and audio going back in-sync. Considering a bunch of these mention Initialize/Deinitialize I suspect this is resetting something involved with the playback.

I've seen some other issues that sound similar, however they appear to be platform or input specific (e.g. #14987 references a commit that seems specific to Android, #14985 mentions sync problems only with SD content but the symptoms sound like they occur sooner and only with IPTV?)

Your Environment

Used Operating system:

  • [ ] Android

  • [ ] iOS

  • [ ] Linux

  • [ ] OSX

  • [x] Raspberry Pi

  • [ ] Windows

  • [ ] Windows UWP

  • Operating system version/name: LibreELEC (community): devel-20181211081404-6db1ac5 9.0,

  • Kodi version: 18.0-RC2

(Compiled from LibreELEC source on 11th December, 2018 - I've not made any changes to the source.)

andrewgreenwood avatar Dec 12 '18 14:12 andrewgreenwood

I've been experiencing this as well, and also that black frame visible in your video at 0:14-0:15.

I was about to report it as well but you got ahead of me :D Thanks.

nsenica avatar Dec 12 '18 15:12 nsenica

as it occurs with other low-resolution videos in my media library (I tried one that was 368x272).

@andrewgreenwood could you please share a log which shows the playback from your media library?

DaVukovic avatar Dec 12 '18 16:12 DaVukovic

I gave this some further testing and it seems not all non-HD content is affected. In particular, the video I tested with a resolution of 368x272 seems to play back without lag now. Possibly this particular example might be affected by some of the options I've switched on/off - I'll focus on the ones that are consistent.

Here's a log showing several files being played back from my media library: https://paste.kodi.tv/baxotizita.kodi

And the corresponding media information is as follows:

08:08:17 - The Brittas Empire - S01E01 - Laying the Foundations.mkv Resolution: 720x576 Frame rate: 25fps Audio rate: 48kHz Has lag issue: Yes Video of problem: http://misc.greenwoodprojects.net/brittas.mp4

08:10:21 - Firefly S01E01 - Serenity.mkv Resolution: 720x576 Frame rate: 25fps Audio rate: 48kHz Has lag issue: No

08:12:27 - Flight of the Conchords - S01E01 - Sally.mkv Resolution: 720x576 Frame rate: 25fps Audio rate: 48kHz Has lag issue: Yes Video of problem: http://misc.greenwoodprojects.net/conchord.mp4

08:15:12 - Whose Line is it Anyway (UK) - S01E02.avi Resolution: 368x272 Frame rate: 29.97fps Audio rate: 48kHz Has lag issue: No

andrewgreenwood avatar Dec 13 '18 08:12 andrewgreenwood

do you still have the problem? this https://github.com/xbmc/xbmc/pull/15078 fixed it for me

M2k80 avatar Dec 20 '18 15:12 M2k80

That PR should only affect Android and not RPi :( it would be weird if that would have fixed this.

nsenica avatar Dec 20 '18 17:12 nsenica

Sorry, I have only wrote, cause it was referenced.

Am Do., 20. Dez. 2018, 18:58 hat Nuno Sénica [email protected] geschrieben:

That PR should only affect Android and not RPi :( it would be weird if that would have fixed this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xbmc/xbmc/issues/15044#issuecomment-449083652, or mute the thread https://github.com/notifications/unsubscribe-auth/AF2m1CtnrWgyEbc5YoV7CobhHPC74Wgoks5u68-2gaJpZM4ZPkMQ .

M2k80 avatar Dec 20 '18 18:12 M2k80

I've done some further testing on this today.

I tried Milhouse builds from 1st Dec, 1st Nov and 1st Oct and the problem is present in each of them. So I thought about what I may have changed setting-wise because this was definitely not a problem when I first tried Leia (which was during November IIRC.)

It MIGHT be helped by the "Sync playback to display" option after all, but I need to re-test on a newer version to verify this. I remember that this previously (a couple of months or so back) worked but had the side-effect of making music sound weird due to it changing the pitch during resampling.

However, I think I may have found a workaround: Audio passthrough. Enabling this appears to resolve the problem when using a Pi with my TV.

andrewgreenwood avatar Dec 29 '18 22:12 andrewgreenwood

Audio passthrough has been fine for most content, though I had occasional issues with audio occasionally dropping out when watching certain TV channels via PVR. I suspect this might be related - i.e. if video playback is slower than audio playback then either it just continues to drift further (passthrough disabled) or the audio stops until the video catches up (passthrough enabled).

It feels almost like either the video or audio playback is set to the slightly wrong rate.

I've reverted to using the audio "sync playback to display" option - which seems to work.

I plan to update to the latest Leia release soon so I'll do some further testing afterwards.

andrewgreenwood avatar Jan 29 '19 17:01 andrewgreenwood

@andrewgreenwood can you confirm issue is present with Leia build. Assuming it is, can you provide a sample of a file that shows the problem (e.g. cut a 2 minute clip of a video and provide a link to it).

popcornmix avatar Feb 11 '19 23:02 popcornmix

I can confirm that the same issue is when:

  • newest version of Kodi 18.9 installed on Android TV
  • Raspberry Pi4 servers as NAS

Playing video from other video players doesn't have this issue

pdunauskas avatar Nov 28 '20 06:11 pdunauskas

+1 I can confirm that Issue

I am having this when playing back .TS Records or direct TS Live Streams, the Source is an VU+ Ultimo 4k. Playing Media from other Video Players works fine.

My Setup is an Up-To-Date Kodi 18.9 on Android 9.0 running on an Xiaomi MiBox S

DJPlaya avatar Jan 27 '21 15:01 DJPlaya

Whats the current status of this? Does it still occur with recent nighlies? If not (or if no feedback) I'll close this as obsolete.

enen92 avatar Feb 14 '24 18:02 enen92