Kodi Audio Out of Sync playing file or after seeking

I was using TrueHD in passthrough mode as always.

At least visually, on my setup, there’s no visible difference between all the formats, from TrueHD to PCM (including FLAC), I could swear that the beep occurs at -2 mark.

Curiously enough, from all the modified PhotoJoseph files by R3S3T_9999, the 23.98 test file is the only one featuring a FLAC track after the PCM track

Side note : Everytime Portisch supplies a new img for testing, this file keeps defaulting to track 6 (FLAC) after the update, even though track 1 (TrueHD) is listed as [default] in Kodi. I have to manually set it to TrueHD after each tar img update. After that, as long as I don’t update CE, it keeps that setting for further plays. Upon further investigation, with MKVToolNix HeaderEditor, it appears that this file does not have a “Default” MKV flag in any audio track which leads players “think” that every track is default and end up with the “last one wins” rule.

Yes
Can be observed in Player Process Info
Top line in brackets a/v corrections (50ms)…
And then the number of corrections if any.

Have tested these audio sync files from reset999
Repeatedly.
I find it extremely hard to match the beep with/frames out of sync.???

The more you repeat the test the more your brain wants to correct what your eyes are seeing, and always choose 0 frames…
Stare at -1 and it seems you hear it then??

I think is better to observe Player Process Info live as it happens…

Latency .166 in PP info is hard coded you are saying?

So remove this ,or a toggle switch to adjust/off /on

Ok, here a test version with the “hardcoded” latency removed.
So default it’s now 0ms:

It still can be adjusted my advanced settings by the latency tag.
But I would test everything first on clean, fresh install without any adjustment!

No idea how this will affect users what do not have such issue yet.

EDIT:
There are some ways to get latency from kernel, by frame and also by EDID if supported. So when this is the issue we will need to see how automated adjust latency by the hardware setup.

EDIT2:
Also eARC is not enabled at all in CoreELEC as it should be supported since HDMI2.1 and this is since T7.

I would be careful with using the EDID info inside CE. Most A/V receivers will already take that into account if you enable their audio sync option. At least my Denon does that.

As expected this has removed 4 frames of audio delay for me. Now seems to be sitting around +1 or maybe slightly less. When skipping around I think (will confirm with a video later) I was seeing some small, like single frame, variations in sync - does this build allow for that?


Also the value shown in Player: a:v: often does not match up with what I am seeing at all. Most obvious example is with the DTS track from Audio_Video_Sync_23.976_TEST TrueHD DTS-HD DDP DD PCM.mkv, on initial playback it seems random as to whether that shows ~-0.6, or ~-0.3. After skipping it consistently changes back to the ~-0.3 value. Despite this, the observed audio delay remained consistent - by eye somewhere between in sync and + 1 frame.

Was unable to get a log showing it starting at ~-0.6, when I enabled the logging it kept starting with the ~-0.3 value despite many attempt. Log showing that:
dts_20241123090328_kodi.log (2.8 MB)

edit: on the TrueHD track the value in Player: a:v: appears to be correct, i.e., 0.0… .

Could you expand on what CoreELEC would need to do?

My understanding was that all the eARC stuff related stuff belongs between the TV (eARC TX) and the sound system (eARC RX) and that other devices (i.e. CoreELEC) weren’t required to do anything more than transmit audio/video in sync as they usually would - without needing to consider that eARC is being used later in the chain.

Als make a dmesg | paste of your system.

This delay thing is driving people crazy, me included. I’m almost certain now that I’ve been a victim of confirmation bias in most of my previous tests when doing visual tests.

This new img forced me to change the audio delay settings in a new way. On all other releases, I was “convinced” by the “Delayed by 150-175 ms” delay as it appeared “right” visually. This new img, with a initial delay of 0 changes things. I must now go into the “Ahead by” part of the slider. As far as my brain let me, I can confirm that “Ahead by 250 ms” is the perfect setting on all videos I tested, PhotoJoseph 23.98 modified by R3S3T_9999 included!

To make sure of that, I rebooted to my regular NG nightly (20241109) and “Delayed by 250 ms” also gives the perfect lip sync ! Incredible how confirmation bias can be at play without us noticing :frowning:

So, I don’t think this delay is fixable AFAICS. It only affects 4K content and never HD content, at least in my case. The delay is “constant” as far as I tested throughout ~10 movie samples featuring TrueHD, DTS-MA, DTS:X and EAC-3 and seems to be “Delayed by 250 ms” in Kodi’s audio offset setting.

I’m open to further testing of course in case some new idea comes to light :smile:

Default latency was 163ms for 24hz.
Now you see the real latency of 250ms.

It’s the question if this value can auto detected or not. So please also make a dmesg | paste so I get some I infos like EDID.

The advance setting latency let you tune a different value for different refresh rates I think.

1 Like

Here’s the dmesg content

I’m OK to set advanced settings XML file with some useful information about refresh rates but we also need to distinguish between resolutions. 4K/2160p content requires 250 ms delay but HD/1080p content does not.

Im actually not convinced this is a coreelec issue. I used to have the exact same issue on my Apple TV until I got a new tele.

1 Like

I also don’t think it’s a CE issue, I’m leaning towards a S905X4 issue and/or the driver that supports it.

It’s definitely not the TV (nor the AVR) because I also have a LibreELEC running on 2 mini PCs. An old NUC type PC, a Gigabyte Brix powered by a Core i5-8250U and a real Intel NUC 8 powered by a Core i7-8559U. The Brix is a fine PC per se but riddled with small hardware bugs that really get on my nerves, the biggest one being a firmware bug making it impossible to use 4K. The Intel NUC however runs fine and all my tests with LE showed no issue whatsoever (except the lack of any HDR10+ and DV support of course)

Yeah I alluded to this in my previous post though. I had a shield and an Apple TV and everything worked great on my LG E6 with Yamaha amp. I upgraded my amp to another Yamaha and suddenly it got lip sync issues on HDR material only on my Apple TV. The shield was fine. Fortunately it was a consistent delay so I set up a scene with a delay on my Yamaha amp and assigned it to a button I could press whenever watching HDR material on my Apple TV. Fast forward a year and I buy an LG C9 and everything is flawless again.

Devices can have compatibility issues with other devices and in my case it seemed to be a combination of Apple TV, one of my TVs and one of my amps. It was just something about that chain of devices which was problematic.

Interesting experience. My brand new Denon replaces my fairly old Yamaha (RX-A2030) which couldn’t handle any HDR so I couldn’t perform any meaningful tests on that front. I didn’t test any 4K content because of the Brix bug and I don’t have the Yamaha anymore so I can’t test anew for audio sync issues. The Denon is a joy, I don’t have any issue with it except few quirks about the user experience (menus not wrapping up once top/bottom is reached is really annoying :smile: )

When this latency do cause this issue it’s a generic Kodi issue. It would also than be clear why it’s not visible on every setup.
I will need to analyse your EDID if there is any info or if there is some info in kernel itself to automatically adjust the latency.
If this can’t be detected we might need to tweak the advanced setting about latency to like include resolution same as like the fps.

I really wish Kodi was more like MPV :smile: MPV is lightning fast (seeking in a video is insane compared to any other player), immensely configurable, plays anything and never had any problem, I absolutely love this player.

@Portisch as for the tests, I’m ready :sweat_smile: Anything I can do to help the project. This is the least I can do given the amount of work the CE team already put and the joy CE brings me everyday I use it on my system!

I tested it now myself on my setup and can’t see anything worse than before. Maybe even better for 1080 content.
So maybe remove then hardcoded latency would be a good option.

Have yet to test latest image from Portisch
Previous image test files at 24 fps
Refresh rate is matched at 24 hz
Latency .166

Playback Joseph test file at 25 fps
And refresh rate doubles to 50 hz
Latency is halved to .080

I do not have much in Library at 25 fps
Some old webrips of the series Black Sails
Same results

So any Playback greater than 24 fps kodi defaults the refresh rate???

Will have a test of latest Portisch image with Latency removed

25 and 30fps will play in Kodi with double refresh rate. This can be disabled via the whitelist

1 Like