fix: calculate EXT-X-START TIME-OFFSET from actual playlist end for live streams#1599
Merged
Essk merged 1 commit intovideojs:mainfrom Jan 19, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1599 +/- ##
=======================================
Coverage 84.00% 84.00%
=======================================
Files 44 44
Lines 11710 11713 +3
Branches 2625 2625
=======================================
+ Hits 9837 9840 +3
Misses 1873 1873 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e7da3c5 to
2b1a1d7
Compare
gkatsev
approved these changes
Jan 15, 2026
src/playlist-controller.js
Outdated
| const liveEdgeDelay = Vhs.Playlist.liveEdgeDelay(main, media); | ||
| const actualPlaylistEnd = seekableEnd + liveEdgeDelay; | ||
|
|
||
| startPoint = Math.max(actualPlaylistEnd + offset, seekable.start(0)); |
Member
There was a problem hiding this comment.
question(non-blocking): While it is only a "SHOULD NOT" in the spec, should we clamp to seekableEnd here? To disallow a negative offset that would end up within the live edge delay?
…ive streams For live streams with negative TIME-OFFSET in EXT-X-START, the offset was incorrectly calculated from seekableEnd, which already has liveEdgeDelay subtracted. This caused playback to start further behind the live edge than intended. Per HLS spec, negative TIME-OFFSET should be relative to the end of the last Media Segment. This fix adds liveEdgeDelay back to seekableEnd before applying the offset, making VHS behavior consistent with native HLS implementations (e.g., Safari). Example: With liveEdgeDelay=18 and TIME-OFFSET=-18: - Before: startPoint = seekableEnd - 18 (36s behind actual live edge) - After: startPoint = seekableEnd (18s behind, matching Safari)
2b1a1d7 to
1dd360c
Compare
|
Congrats on merging your first pull request! 🎉🎉🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes incorrect start position calculation for live streams with
EXT-X-STARTcontaining a negativeTIME-OFFSET.The offset was being calculated from
seekableEnd, which already hasliveEdgeDelaysubtracted. This caused playback to start further behind the live edge than intended, making VHS behavior inconsistent with native HLS implementations (e.g., Safari).Example with
liveEdgeDelay=18andTIME-OFFSET=-18:startPoint = seekableEnd - 18(36s behind actual live edge)startPoint = seekableEnd(18s behind, matching Safari)Changes
liveEdgeDelayback toseekableEndbefore applying negativeTIME-OFFSET, per HLS spec which defines negative offsets as relative to the end of the last Media SegmentseekableEndto prevent small negative offsets (e.g.,-5) from seeking into the unsafe live edge buffer zoneTIME-OFFSETTest plan
liveEdgeDelayreturns 0)