Skip to content

Conversation

@LorDisturbia
Copy link

@LorDisturbia LorDisturbia commented Jan 15, 2026

Summary

Fixes incorrect start position calculation for live streams with EXT-X-START containing a negative TIME-OFFSET.

The offset was being calculated from seekableEnd, which already has liveEdgeDelay subtracted. 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=18 and TIME-OFFSET=-18:

  • Before: startPoint = seekableEnd - 18 (36s behind actual live edge)
  • After: startPoint = seekableEnd (18s behind, matching Safari)

Changes

  • Add liveEdgeDelay back to seekableEnd before applying negative TIME-OFFSET, per HLS spec which defines negative offsets as relative to the end of the last Media Segment
  • Clamp result to seekableEnd to prevent small negative offsets (e.g., -5) from seeking into the unsafe live edge buffer zone
  • Add test case and manifest for live streams with negative TIME-OFFSET

Test plan

  • Existing tests pass
  • New test verifies correct behavior for live + negative offset
  • VOD behavior unchanged (liveEdgeDelay returns 0)

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.00%. Comparing base (bd810ea) to head (1dd360c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LorDisturbia LorDisturbia force-pushed the fix/ext-x-start-live-edge-delay branch from e7da3c5 to 2b1a1d7 Compare January 15, 2026 14:17
Copy link
Contributor

@Essk Essk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

const liveEdgeDelay = Vhs.Playlist.liveEdgeDelay(main, media);
const actualPlaylistEnd = seekableEnd + liveEdgeDelay;

startPoint = Math.max(actualPlaylistEnd + offset, seekable.start(0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
@LorDisturbia LorDisturbia force-pushed the fix/ext-x-start-live-edge-delay branch from 2b1a1d7 to 1dd360c Compare January 16, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants