Skip to content
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: issues with live playback timing #1553

Merged
merged 4 commits into from
Nov 18, 2024

Conversation

alex-barstow
Copy link
Contributor

@alex-barstow alex-barstow commented Nov 15, 2024

Description

This PR fixes 2 issues:

Issue 1:

If you wait to start playback of a sliding window livestream, playback will not start from the live edge. This is because the seekable range does not update correctly on playlist refreshes before playback starts. For a sliding window livestream, here's an example of how the seekable range should update on playlist refreshes:

// segment duration of 5s
Initial range: 0 -> 1000
1st refresh: 5 -> 1005
2nd refresh: 10 -> 1010

But before playback starts, what we get now is this:

Initial range: 0 -> 1000
1st refresh: 0 -> 1000
2nd refresh: 0 -> 1000

So when playback starts, we seek to 1000 thinking it is the seekable end, but that puts us behind the true seekable end of 1010.

This happens because before we fetch the first segment, what we do now is calculate the seekable end as the duration of the segments in the playlist without updating the base start time when segments expire off the start of the playlist.

Solution:

Calculate the seekable start and end using MediaSequenceSync start and end times, which are already accurately updated whenever a new playlist is loaded. By using these values that are already available we can bypass all the complexity of the current calculations.

Issue 2:

Occasionally, when switching renditions, playback will not continue from the same place in the stream but will jump way back. This is caused by a race condition-- it is possible to switch to a new media playlist that has a Media Sequence value less than the current Media Sequence value, which presumably can result from delays on the media server updating playlists across renditions.

Solution:

If we switch to a media playlist with an older/lower mediaSequence value, we now calculate the base time by extrapolating backwards from a known segment start time rather than falling back to the currentTime.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@9f1c4ad). Learn more about missing BASE report.
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/playlist-controller.js 93.02% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1553   +/-   ##
=======================================
  Coverage        ?   84.11%           
=======================================
  Files           ?       43           
  Lines           ?    11646           
  Branches        ?     2604           
=======================================
  Hits            ?     9796           
  Misses          ?     1850           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@alex-barstow alex-barstow merged commit 6b4b7e2 into main Nov 18, 2024
15 checks passed
@alex-barstow alex-barstow deleted the fix/seekable-range-calculation branch November 18, 2024 21:35
@alex-barstow alex-barstow changed the title fix: issues with playback at the live edge fix: issues with live playback timing Nov 18, 2024
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.

2 participants