Sound and video asynchronous for H.264 with AAC on raspberry pi3

I meant by changing the settings in the InputStream Adaptive add-on so it was grabbing a 720p stream instead of the 1080 it shows in your logs. That or lower the max bandwidth there. It was looking like the default was 4mb/s and it showing you only getting around 3mb/s. But, I really don’t know anything about add-ons like this so don’t take what I post as authoritative.

Yes, I think so. HW acceleration should be enabled. My guess is that there is some setting which might trigger my problems.

Regards, Michael

@darwindesign: I’ll check that. When I display the playback resolution (info button) it tells me 720p as expected. And of course the raspi shouldn’t upscale.

I’ll look for those settings.

Regards, Michael

There seems to be no addon named Inputstream adaptive. I’ve tried to follow How to Install InputStream Adaptive on Kodi Matrix and Leia
But I can’t follow step 6 - there is no menue Video Inputstream. I also couldn’t locate that addon by searching the addon database from within kodi.

But there is an option within ARDundZDF to select a resolution. It was set to 1920x1080. Changing it to 1280x720 didn’t help.

Any ideas?

Regards, Michael

It’s included in OSMC. On my RPi it’s under My Add-ons->VideoPlayer InputStream and I think it’s automatically activated by add-ons that need it (I have iPlayer and YouTube, eg).

Thanks for that hint. Thus I could locate this addon. I limited both max resolution settings to 720p, but still sound is around 5s ahead.

Additionally there is the addon “Inputstream FFmpeg Direct” being deactivated. I did activate it. Again no improvement.

Is it necessary to restart kodi to activate such changes?

Regards, Michael

Addendum: One can select within the addon ARDandZDF the stream quality. If I go down to 960x540 video, sound is in sync within 3sat streams.

To my surprise the SWR streams are also available as 1920x1080. But SWR streams are out of sync at all resolutions!?! Does it matter wether one uses mp4 or hls (mp4 streams are mostly not available)?

Have you tried this with Kodi on another platform (e.g. Your PC?)

Yes, just verified it on my laptop. All videos from all stations (ok, 3sat and SWR) in all resolutions are in sync (maybe apart by some ms). I hav tried the most recent kodi 19.4 as available within linux tumbleweed. Of course ma laptop uses a different hardware acceleration…

Regards, Michael

Do you have one particular stream that you can reproduce the issue with so that we can try the same here?
Best would be one without geoblocking.

Also would then be interesting if you have the same issue using a different Addon to play the Stream (like the Mediathekview Addon Aktuelle Release Ankündigungen | MediathekView-Forum)

I encounter that problem with any stream. I’ve also tried the 3sat addon as provided within the standard repository with the same problem. For testing I typically select some news show.

But I don’t have this issue with the addon ctuplink. It, too, is H.264/AAC.

I was in contact with the developer of ARDundZDF - nobody seems to suffer under my offset issue.

Regards, Michael

Ok I just installed that Addon and played the first episode of “Die Anstalt” and the audio was perfect in sync.

May I suggest you do a fresh install on a second SD Card and test with that.

I tested “Die Anstalt” just now (I selected the first in the list being the most recent one - “simulating” star trek enterprise). And there was the long delay of the video by around 5s.

I’ll have to do a fresh install anyhow when OSMC’s bullseye release will become available. I’ll report then…

Regards, Michael

I’ve discovered a solution (better a workaround)!

To my surprise there is no offset between sound and video when I DEACTIVATE HW acceleration. Then all videos are played fine (but the processor is more busy). But I seem to be limited to 720p - that’s not an isue in Germany since all our HD channels are 720p.

These are my settings:

System>Player>Videos>adjust display refresh rate> set to on start/stop
System>Player>Videos>use DRM PRIME decoder> set to no

Addons>User Addons>Video player InputStream Addons>InputStream Adaptive>max. resolution> set both to 720p

Addons>ARDundZDF>Allgemein>Sofortstart> set to on
Addons>ARDundZDF>Modul-Einstellungen>Videoformat> set to HLS(adaptive)
Addons>ARDundZDF>Modul-Einstellungen>Videoqualität> set to 1280x720

I guess that the settings within ARDundZDF are overrruled by the settings for InputStream adaptive.

Thanks to darwindesign for bringing InputStream Adaptive into my mind.

Regards, Michael

1 Like

I’m still doing some experiments to find out why DRM PRIME fails. Thus I’ve selected all default settings for player and videos sections within OSMC 19.4 (thus HW acceleartion will be enabled). And I’ve set the whitelist as recommended within the HOWTOs. Then I’ve watched different streams from German broadcast services (arte - 3sat - SWR), and ctuplink. To my surprise videos from arte are in sync (as are those from ctuplink). But 3sat and SWR fail with big offsets between sound and video. Inspecting the kodi.log unrevealed a potential reason: ctuplink is sending with 30 fps 1280x720 - being rendered with 60 fps. arte is sending with 25 fps 1280x720 - being rendered with 50 fps. Otherwise 3sat is using 50 fps 1280x720 - a supported resolution, but out of sync. And SWR is even using 50 fps 1920x1080 - again a supported resolution, but out of sync.

Conclusion: My pi3 seems not to be capable to support input stream with fps higher then 30. I was not aware of those differences among the input streams - all claim to be 720p H.264 with AAC sound. The different fps is somewhere behind the scene, but probably important.

Regards, Michael

The only difference I can see between your Pi3 and mine (which plays 720p50 from 3sat just fine) is I’m on Debian Bullseye so maybe you could give that a try.

@grahamh : Thank you very much for your patience. And for your hint that it is working fine with bullseye. Since I’m running some other tasks, too, on my OSMC pi3, I will wait for the final OSMC bullseye release. Otherwise my other tasks would be interrupted - not so good for e.g. my 24/7 weather station:-) BTW - it is really astonishing how many tasks work in parallel on such a small device without any trouble.

Regards, Michael

We’ve just noticed you have Audio output set to ‘Optimized’. Try ‘Best match’.

No improvement. But audio works fine, it’s just some seconds ahead. And the offset increases continuously. It feels, as if the video cannot be rendered “fast” enough and is played instead slightly slower than the audio. Thus the audio is more and more ahead.

Regards, Michael

News w. r. t asynchronous sound and video within the addon ARDundZDF. It has resolved by itself. Now sound and video are perfect in sync, even for 1080p streams. Of course there were some updates for that addon. But I also had to reboot my raspi3 (because I wanted to replace my power strip). There was no change in configuration of kodi 19.4 ressp. OSMC).

My guess: rebooting did the trick. My raspi is typically up 24/7 for months. But I start kodi always when I want to use it and stop it afterwards (using systemctl).

Regards, Michael

Addendum 2022-07-11: Sadly, after some days the videos again are out of sync. Thus there seems to be a kind of “aging” which triggers my problem. I’ve checked some possibilities: memory shortage - no (only ~150M used when kodi is not running), performance - no (as top has proven), no related error messages within dmesg and journalctl, HDMI problem - no (problem occurs even when I ensure proper power on of involved HDMI devices).

Kodi forum suggests to me that I should overclock my pi3 to get smooth 50fps playback. But I hope that there is a better, permanent solution. Suggestions are welcome.
BTW, to overclock is within known issues of libreelec for raspi 3, see LibreELEC (Matrix) 10.0.2 - LibreELEC

1 Like

@grahamh: Now with the freshly released bullseye release of OSMC from 2022-09-18 my problem is resolved: sound and video are in sync.

Regards, Michael

1 Like