Bug Kodi loses AV sync when playing videos that exceed CPU resources
#1
TL;DR: When playing high-bitrate HEVC (H265) videos on a weak CPU, saturating the CPU causes A/V sync to be lost, permanently.

The issue
I am having serious A/V desync issues when playing my HEVC-encoded Blu-ray (1080p) content on a relatively weak laptop (specs and debug log below). My videos are encoded with a target bitrate of 1200kb/s for the video stream. Most of the time, the videos play just fine. However, in scenes with especially high detail (e.g., panning across a forest scene with lots of trees), the instantaneous bitrate jumps dramatically, and the laptop cannot keep up: all four CPU cores spike to 100%, and video playback stutters badly...frame rate feels like ~2 FPS for a few seconds. The original Blu-ray stream plays fine on this machine (presumably due to offloading the decoding to the GPU), and the HEVC-encoded file plays just fine on my more powerful desktop PC.

Since I'm exceeding the CPU's capabilities in this case, I expect sub-optimal playback. And, when using VLC to play the same video on the same machine, I encounter playback problems in all the same places as with Kodi. What I don't expect is that the video decode slows down to non-realtime, but the audio track just keeps playing normally (thus getting badly ahead of the video stream), and never fixes itself, even when the instantaneous bitrate drops back down to something the CPU can handle. Whenever I hit one of these "too high bitrate" sections, the video ends up permanently slipped behind the audio, effectively making the the video unwatchable in Kodi. I've tried all of the A/V sync methods, and they all lose synchronization in this situation (it's as though Kodi doesn't realize that it's lost sync, so it's not trying to correct).

VLC does not have this problem. When it hits these problematic sections, VLC realizes that it's not able to keep up, and does a "best effort" decode (which may include degraded frame rate, severe blocking artifacts, and complete loss of chroma information) until it gets past that section, but it still maintains audio sync throughout. (My guess is that VLC is simply aborting the rendering of the frame if it takes too long, and showing whatever garbage it managed to decode.) It sucks, and I'm not convinced that the VLC experience is better than simply dropping a whole lot of frames, but at least it recovers A/V sync afterward. Kodi needs to do better here...regardless of what "degraded mode" playback looks like, it must restore A/V sync once past the problematic frames.

Specifics
Reply

Logout Mark Read Team Forum Stats Members Help
Kodi loses AV sync when playing videos that exceed CPU resources0