(Possible Solution) Audio resume problem with LibreELEC 9.0 (issue not present in LibreELEC 8.2.x)

  • Running LibreELEC 9.0 on Android TV box - S905X with 2GB ram and 16GB internal memory, running LE from 32GB class10 SD card. This issue is not present with LibreELEC 8.2.x, or Kodi Leia on Windows 10 or Android. I've provided a sample highlighting the issue (below) and this should help devs to re-create and hopefully fix the problem. Also debug log is provided with audio, video and audio/video timing information component specific logging turned on.

    I’ve noticed that occasionally when resuming playback on a video, there is no audio for up to several seconds. I think there is a pattern to this on the testing I have done so far and it appears to be related to video keyframes (i.e. video resumes at previous keyframe whereas audio resumes at "actual" resume time). There was a change done in LibreELEC (version 8 - Kodi 17.6), where resumption of video playback was fixed to look for the previous keyframe as the resumption point (it used to look for the next keyframe). Here is the link from the libreelec forum, see post 1,244 concerning PR11713:- Fix for resuming playback in Kodi - link to PR11713

    For example up until this change, if you stopped playback at 5:00, where the previous keyframe in the video stream was at 4:55 and the next keyframe was at 5:05, then when resuming playback, the video would start at 5:05 (5 seconds too late). After this fix, the video resumed at 4:55 (and audio also re-started at 4:55). With the vast majority of video streams it appears that video keyframes are very close to each other, and the time difference between the previous video keyframe resume time and the "actual" resume time is negligible, so you won’t notice any audio problems. I’ve found that very occasionally, the gap between keyframes can be several seconds, and what appears to be happening here is that whilst the video resumes at the previous keyframe, the audio seems to resume at the "actual" time playback was stopped. So, using the above example, playback between 4:55 and 5:00 would mean no audio was heard, and once we reached 5:00, the audio resumed.

    I've posted a link to a small 15Mb sample.mkv showing the issue where the gap between keyframes is several seconds. If you stop playback at 40 seconds, then resume from there, you should notice that video playback resumes from about 33-34 seconds, and there is no audio until you hit the 40 second mark. (You may need to add the following to your Kodi "advancedsettings.xml" file or the video won't be marked as "in progress"):-

    <advancedsettings>

    <video>

    <ignoresecondsatstart>30</ignoresecondsatstart>

    </video>

    </advancedsettings>

    It does appear that audio always resumes from the resume time regardless of where the previous video keyframe is. This issue is not present using LibreELEC v8.2.5 (Kodi 17.6). With that version the video resumes from 33 seconds with accompanying audio.

    Link to sample. Audio resume sample

    Link to debug log with video, audio and audio/video timing component specific logging turned on. This log is for the resumption of playback from 40 seconds, where video resumes from about 33-34 seconds and the audio is dropped until the 40 second mark. http://ix.io/1bkp

    Edited 10 times, last by ukmark62 (February 22, 2019 at 1:56 PM).

  • FYI, I've found a possible fix for this. I also use CoreELEC, and both LibreELEC and CoreELEC have exactly the same issue on my S905x amlogic box.

    Namely, in the kodi file videoplayer.cpp file, I removed the line number 1341:-

    FlushBuffers(starttime / 1000 * AV_TIME_BASE, true, true);

    I forked CoreELEC, made the above change with a patch to remove the line and made a test image - that’s the only change from CoreELEC master.

    Now, the audio is heard immediately upon resume. So far I’ve not had any issues.

    This line was not present when PR11713 was first done, so I thought I'd remove it and give it a go. All looking good so far....