Fix gaps introduced in video buffer by remuxer work-around #2894
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 PR will...
Why is this Pull Request needed?
Fix gaps in buffer for streams with variable framerate or other PTS/DTS inconsistencies that caused the "Video: PTS/DTS adjusted" workaround to kick in when it should not.
hls.js was shifting the start of the first frame of some segments back about a frame's duration, which cleared the previous frame from the buffer causing buffer gaps. I don't see how we could accurately estimate the last AVC frame duration (
lastFrameDuration
ormp4SampleDuration
) to get the estimatednextAvcDts
to be spot on - not sure it can always be. So to prevent these overwrites, ignore assumed AVC DTS "holes" that are smaller than the average frame duration.https://github.com/video-dev/hls.js/pull/2894/files#diff-14a34ee6c08b15d0e309d10c2c05f3d0R264-R273
We were using the PTS diff between initial audio and video samples to calculate
timeOffset
for each segment. This should done using DTS (as outlined in the comments and based on howtimeOffset
is used inremuxVideo
) but was changed to PTS to align the start of buffered media to0
.With these changes, we'll only use PTS at the very start of a VOD, when the initial time offset is
0
, and DTS for the rest. This will prevent false positives when detecting gaps or overlap in AVC DTS inremuxVideo
.https://github.com/video-dev/hls.js/pull/2894/files#diff-14a34ee6c08b15d0e309d10c2c05f3d0R52-R60
Checklist