Video and audio playback gradually becomes out of sync

Hello, I have a very strange behavior with my Rasperry Pi 2 with Kodi and OSMC (current version): when I play a video (only certain ones) first the audio and video playback is synchronous and gradually the audio playback comes earlier and earlier than the video playback. After about 4 minutes the video hangs briefly, the video playback bar becomes visible (as if something had to be reloaded) and the video and audio playback is synchronized again. The whole thing then repeats itself again and again.

Kodi Version: Starting Kodi (19.4). Platform: Linux ARM (Thumb) 32-bit
OSMC Version: 2022.09-1

I think it has to do with the Video. So here is the MediaInfo: Untitled - Pastebin.com

I remembered that among other videos, I was able to watch this video smoothly and without errors on the same Rasperry Pi 2 about a year ago. So it must have gotten worse with updates. I would be very happy if someone could help me.

I have opened a similar thread here as well: Video and audio playback gradually becomes out of sync

Hard to say without logs – but as you’re playing an AVI and an old format it’s probably experiencing a discontinuity.

An xvid with a shifted frame rate and a mp3 soundtrack. Those were the bad old days. Personally I would just run it through Handbrake and convert it to h.264 and AC3 and call it a day.

You are absolutely right here the full debug log: hastebin

I know this is off-topic in the context of this thread: but what are your settings on Handbreak? I always get bigger files afterwards than before. Although H.264 should compress better than XVID or?

You want the file to be be bigger if your transcoding since the process is going to cause degradation and allowing for less compression (a larger file) is going to help minimize how noticeable this is. There isn’t going to be a huge efficiency difference between XVID and AVC since they are both based off the same type of compression standard. I don’t really want to dive into settings since there is a lot of them and the information is easy enough to find with a web search. What I will say is figure out everything other than the quality slider. Anything you don’t understand what it does just look it up. Next change the range setting to seconds and pick a few minutes of the video where there is plenty of motion or other things that may be prone to showing artifacts/degredation. Set the video settings to constant quality, and then run transcodes with it set to 16, 18, 20, and 23 (of course changing the file name each time to mark which setting you used). Take a look at the results and run more settings if you feel the need. Once you find the setting where your not happy just run the entire file with the next higher quality setting. On the odd occasion where I’m dealing with this I normally end up with a file size 2-3x larger than the original. I would argue this to be a non-issue since old XVID files are normally very small so the end result is a still not particularly large file that still looks the same but plays back without issue on everything.