-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(hls): Fixed buffering issue with live HLS #4002
fix(hls): Fixed buffering issue with live HLS #4002
Conversation
HLS now appends segments in sequence mode. In order to handle seeks, we use the timestampOffset property to inform MediaSource where the new segment should go. However, we were still setting timestampOffset when the manifest was updated, which caused issues in live HLS; suddenly, MediaSource would start inserting segments near the start of the presentation, rather than at the live edge. This changes MediaSourceEngine to not apply timestampOffset during initialization when in sequence mode, to fix that problem.
9e54a87
to
f04d314
Compare
I don't think I understand this part. Can you elaborate? I don't doubt your fix, but I think we need to find a better way to explain why it's the right one. |
Updated PR description to reflect our discussion of the issue and the fix. Please add a commit or amend to remove the timestampOffset parameter in HlsParser's createSegmentReference_, and to hard-code timestampOffset to 0 there instead. |
When in sequence mode, we no longer use the timestamp offset of segment references. So, in the HLS parser, there's no reason to set it anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is awesome.
HLS now appends segments in sequence mode. In order to handle seeks,
we set the timestampOffset property on SourceBuffer to the startTime of
the segment. This is done after every seek, or on startup.
For non-sequence-mode content (DASH), we normally set timestampOffset
based on the Period structure. This should be suppressed in sequence
mode, though, where only the reference startTime matters.
The buffering issue was caused by two things in combination:
change when a playlist was updated
even though this should be skipped in sequence mode
These two things in combination would lead MediaSourceEngine to start
inserting segments near the start of the presentation, rather than at
the live edge.
This changes MediaSourceEngine so that in sequence mode, timestampOffset
is ignored in setStreamProperties. This also cleans up the HLS parser
to set each reference's timestampOffset to 0, since they should be
ignored anyway.