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

Feature/v1.0.0 Latency Controller change playbackRate frequently #3240

Closed
mnikn opened this issue Nov 19, 2020 · 2 comments
Closed

Feature/v1.0.0 Latency Controller change playbackRate frequently #3240

mnikn opened this issue Nov 19, 2020 · 2 comments

Comments

@mnikn
Copy link
Contributor

mnikn commented Nov 19, 2020

Is your feature request related to a problem? Please describe.
Now latency controller will change video playbackRate when (level.edge - currentTime) is more than 0.5s, thus the video playbackRate are hard to maintain in 1, which will cause a poor user experience.

Describe the solution you'd like
Is it possible that add some params to customize latency controller behaviour, eg:

{
  // when (level.edge - currentTime) are more than threshold, it will consider to change playbackRate
  distanceFromEdgeMaxThreshold: number;
  // (level.edge - currentTime) more than threshold time limit duration
  distanceFromEdgeThresholdDuration: number; 
  // when canReduceLatency is false, won't do any playbackRate change
  canReduceLatency: boolean;
} 

The sample code:

let edgeThresholdStartTime = 0;
function checkLatency() {
  if (!config.canReduceLatency) {
    return;
  }
  if (distanceFromEdge >= config.distanceFromEdgeMaxThreshold) {
    if (edgeThresholdStartTime === 0) {
      edgeThresholdStartTime= performance.now();
    }
  }
  if (edgeThresholdStartTime !== 0 && performance.now() - edgeThresholdStartTime >= config.distanceFromEdgeThresholdDuration) {
    doPlaybackRateChange();
  }
}
@mnikn mnikn changed the title Latency Controller change playbackRate frequently Feature/v1.0.0 Latency Controller change playbackRate frequently Nov 19, 2020
@robwalch
Copy link
Collaborator

@mnikn This will be resolved in an upcoming release with auto low-latency mode. I'll put this issue next to the note in progress in https://github.com/video-dev/hls.js/projects/7

"auto" lowLatencyMode
Switch from part loading with playbackRate adjustment to fragment loading at 1x speed based on currentTime's proximity to the playlists part list.

Since users may want to use the latency controller with non LL-HLS streams I may add another option, or use a value between hls.targetLatency and liveMaxLatencyDuration(Count) to determine when playback rate adjustment kicks in.

Thanks for suggesting canReduceLatency, but I think a distance to edge threshold in seconds, would be a better option, along with an idea for how we could calculate this when the user doesn't specify a value, as a fixed value really wouldn't be appropriate.

@robwalch robwalch added this to the 1.0.0 milestone Nov 19, 2020
@robwalch robwalch added this to To do in Low-Latency HLS (LL-HLS) via automation Nov 19, 2020
@robwalch robwalch moved this from To do to In progress in Low-Latency HLS (LL-HLS) Nov 19, 2020
@robwalch
Copy link
Collaborator

robwalch commented Dec 8, 2020

@mnikn there is a fix for this issue in https://github.com/video-dev/hls.js/releases/tag/v1.0.0-alpha.3

@robwalch robwalch closed this as completed Dec 8, 2020
@robwalch robwalch moved this from In progress to Done in Low-Latency HLS (LL-HLS) Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants