Fix Safari video playback, and fragment timing #2902
Merged
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...
nextAvcDts
estimation to avoid false hole/overlap detection.fragment.minEndPTS
nextLevel
(prevents gaps when adapting fmp4 and the previous segment's media extends past the target segment's start in "HLS fMP4 by Bitmovin")initPTS
and TS AV time-offset in remuxer (since the first sample PTS is not always the fragment start)These changes also help make fragment DTS and PTS updates more stable on adaptations, when reloading previously parsed fragments, and when simply forward buffering. The demo timeline was updated to help in this effort by outlining the current, and loading levels in different colors.
Why is this Pull Request needed?
Remuxed AVC video is not buffering at all in Safari without removing these workarounds. These workaround may have been for Safari 9 to avoid buffer gaps and decode errors, but I don't see any issues with most video in Safari 10.1 and up. Or not...
The PTS > DTS workaround did not work in Safari and was probably the reason for most if not all the Safari specific code. Safari has very little tolerance for composition time offsets that are not close to the video framerate (cts of 0 causes decoding glitches or dropped frames and frames with large cts are thrown out).
Estimating the start of the next fragment correctly is very important because we use
frag.startPTS
orfrag.start
as the time-offset passed to the remuxer which is used to establish "initPTS". It can determine where media is appended as well as if parsed timecode should be shifted. With these changes we get the nextfrag.start
right most of the time, so fragment times are updated more accurately and don't change each time they are reloaded and parsed.There's also a few other fixes:
Resolves Issues:
#1801
#2122
Checklist