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: support timeshift dash manifests without startNumber attribute #1092

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ziddey
Copy link

@ziddey ziddey commented Mar 11, 2021

Description

This should bring support for live DASH assets that utilize timeShift (sliding window) and $Time$ as opposed to $Number$ (no startNumber attribute). Would fix #256

For such manifests, mpd-parser will always set mediaSequence to 1. Consequently, SegmentLoader will be unaware of any live window shifts.

Specific Changes proposed

Instead, we need to derive an appropriate mediaSequence on each playlist update so the window can shift accordingly. We can take the first segment of the new playlist and find its index in the old playlist (we can search by the segment's uri). This is the number of shifts, or change in mediaSequence.

In the event the segment isn't found (e.g. network issues preventing manifest update), we can instead advance the entire length of existing segments, which should then simulate falling behind the live window and trigger a reseek.

This derivation only needs to occur for this type of DASH asset, but it should not cause issues otherwise since it should end up deriving the same value. It should generally be sufficient to check that the new playlist has a mediaSequence of 1, but maybe there's a more definitive way? We could then also check that the new sequence <= the old one (to exclude a playlist naturally going from 0 to 1).

Requirements Checklist

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

@welcome
Copy link

welcome bot commented Mar 11, 2021

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@ziddey
Copy link
Author

ziddey commented Mar 11, 2021

Can segments ever evaluate false? If it's always an array, even if empty, we could just check b.mediaSequence === 1 && b.segments.length.

In general, it may be worth considering scenarios where a playlist goes from not having segments to having segments and vice versa and how to handle setting the mediaSequence

Logically, the dashPlaylistUnchanged function may not the most ideal place for this fix, but it was easiest to implement here. Maybe someone more familiar with the codebase could move it somewhere more appropriate?

I've setup a temporary demo which now plays the Unified Streaming Live DASH stream here

Note this fix may not completely solve issues with playing these types of assets. While I've now had the above stream playing continuously for almost a day without issue, I am seeing similar streams stop randomly. It seems to stop fetching the manifest entirely, and I'm not seeing anything that stands out in the debug log. When this happens, vhs.playlists.minimumUpdatePeriodTimeout_ becomes null, while vhs.playlists.master.minimumUpdatePeriod still has the proper value. It can happen almost right away or sometimes up to an hour into the (same) stream.

@gkatsev
Copy link
Member

gkatsev commented Mar 11, 2021

PRs are also built automatically via netlify, so, your changes are lives here https://deploy-preview-1092--videojs-http-streaming.netlify.app/ (see the netlify checks)

@ziddey
Copy link
Author

ziddey commented Mar 11, 2021

I believe I've identified the next issue. For an HLS stream, when changing quality, the media manifest for the old quality is no longer refreshed. Unfortunately, this is also being applied for DASH streams.

ApplicationFrameHost_m4MbM9Pm3Z

Note this isn't an issue with the Unified Streaming Live DASH stream since it only has one quality.

@ziddey
Copy link
Author

ziddey commented Mar 11, 2021

Added a sourceType check to onGroupChanged to not stop the playlist loader for dash sources.

What ramifications does this have on switching from demuxed to muxed audio? As it was, I'm not sure those conditions would have evaluated true.

@ziddey ziddey force-pushed the fix/dash-media-sequence branch from 12ff826 to 8692dc7 Compare March 11, 2021 10:56
@ziddey ziddey force-pushed the fix/dash-media-sequence branch from 8692dc7 to 6967321 Compare March 12, 2021 23:31
@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #1092 (b848006) into main (0964cb4) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head b848006 differs from pull request most recent head e5beaea. Consider uploading reports for the commit e5beaea to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1092      +/-   ##
==========================================
- Coverage   86.31%   86.30%   -0.01%     
==========================================
  Files          39       38       -1     
  Lines        9807     9079     -728     
  Branches     2279     2061     -218     
==========================================
- Hits         8465     7836     -629     
+ Misses       1342     1243      -99     
Impacted Files Coverage Δ
src/dash-playlist-loader.js 89.66% <100.00%> (-0.43%) ⬇️
src/media-groups.js 98.91% <100.00%> (+0.24%) ⬆️
src/playlist-loader.js 91.40% <0.00%> (-3.64%) ⬇️
src/playlist-selectors.js 85.23% <0.00%> (-1.83%) ⬇️
src/util/text-tracks.js 88.29% <0.00%> (-1.33%) ⬇️
src/segment-loader.js 95.32% <0.00%> (-1.02%) ⬇️
src/vtt-segment-loader.js 80.00% <0.00%> (-0.90%) ⬇️
src/sync-controller.js 96.72% <0.00%> (-0.73%) ⬇️
src/videojs-http-streaming.js 90.56% <0.00%> (-0.47%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0964cb4...e5beaea. Read the comment docs.

should allow tests to pass now
@ziddey ziddey force-pushed the fix/dash-media-sequence branch from 52e1549 to b0dcefd Compare March 30, 2021 05:46
@ziddey ziddey force-pushed the fix/dash-media-sequence branch from 11a0115 to 90019fd Compare June 12, 2021 17:32
@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated label Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dash live streaming stops playing after a few seconds
3 participants