Seek at a chunk level when seeking to chunk start positions #1031
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This avoids issues that can arise due to the slight discrepancies between chunk start times (obtained from the manifest of segment index) and the timestamps of the samples contained within those chunks.
This PR adds the equivalent logic of google/ExoPlayer@a4114f5, for HLS TS streams. I have copied the description from that commit.
It is apparent when SeekParameters are used, added for HLS in google/ExoPlayer#9536, that the video sample chosen is not the first keyframe in the chunk, rather the last keyframe of the preceding chunk.
It is ultimately down to using "findSampleBefore()":
media/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SampleQueue.java
Line 978 in f6fe90f
It can be reproduced using the Exoplayer Demo "HLS Apple multivariant playlist advanced (TS)" stream. The first video keyframe PTS in the chunks are offset back by 16.666ms, hence not snapped to. The previous keyframe is used,
some 1983.334ms out of sync with the chunk PTS and that of the audio PTS.
As far as I can tell, it is only visually apparent for tunneled playback where HW AV sync is used, resulting in a jarring acceleration of video decode to catch up with audio.