-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Automatic ABR quality restrictions based on size #2333
Comments
I worry about the expense of polling, especially on embedded devices. A cheap and easy time to check the size is when we go into or out of fullscreen mode, which there are universal events for. It's not clear to me in what other circumstances an application would change the size of the video element. But it does seem clear the application always knows when that happens, because it is the thing changing the size of the element. So I have always felt that the most efficient way to do this is at the app level. But I'll look into what dash.js and hls.js do. Perhaps there's something else I've overlooked. |
hls.js polls the video size once per second to implement the dash.js adds a It's not obvious that this is connected to their Neither relies on One last note from my research: I've also discovered that there is a |
In general, I'm in favor of this option, and I'm in favor of the default being An event-driven solution, such as I'd really like to avoid polling, since polling turns out to be surprisingly expensive in specific cases on devices. (See #2252) Another alternative is to make AbrManager instances aware of the video element and measure its size every time it makes a decision, as dash.js does. This is probably our best option for robustness, but may require changing the plugin interface. |
@joeyparrish I appreciate the time you took into investigating this. Thank you. I looked at the smallest Otherwise, a mix of |
I suspect that making AbrManager aware of the video element should be enough. I'm not sure we should need to poll. The default AbrManager (by design) doesn't make decisions all the time, but only once every so many seconds (8 by default). A custom AbrManager can already make decisions whenever it likes, ignoring the config value for So I think checking the element size when we make decisions should be good enough for the default AbrManager. The only risk in this approach is changing a plugin interface, which must be done carefully and with an eye toward backward compatibility if possible. |
@joeyparrish I agree that checking the video element size every few seconds (8 by default) seems more than enough. What changes in the interface do you expect for this to happen? And do you expect this functionality to be implemented by you or any member of the team in the short term? |
@alejandroiglesias if you want to introduce polling outside of shaka, I guess it would make sense to use the restrictions config in |
This feature will be amazing! 🥳 I think a mix of ResizeObserver and a fallback could be a great solution to get the player size 🤔 With a dash manifest with 720p + 1080p streams and a player resolution of 850p, it could be nice to choose if we want to use the biggest or the smallest video stream (if we don't match the exact resolution) 🙂 |
Thanks @TheModMaker to point me to this issue. He suggested using:
to limit the size of the video choosen by the abr-manager. This works inside a webpage which is not changing in size, but doesn't work for example when switching to fullscreen-mode. In my opinion a polling or continuous tracking of size-changes isn't necessary, it would be greate if maxWidth and maxHeight just adapt when shaka.abr.SimpleAbrManager.chooseVariant is called the next time. |
You make a good point. That would update the restrictions every abr decision interval, which by default is every 8 seconds. That would be sure to be more performant than polling, and at such a long interval, probably close enough in battery performance to listening for size change events. |
I fixed the problem using restrictions: this.player.configure({
restrictions: {
maxHeight: height
}
}); Where height comes from a window resize event. |
Did any of you manage to set ABR restrictions that adapt to player size? |
ResizeObserver is not available on all supported platforms, but is now available on all evergreen browsers. And the platforms that don't support ResizeObserver (TVs, set top boxes, etc) also don't support resizing. So I think it would be reasonable to add this as a built-in feature, inside something like |
@Doolali the problem is that the restrictions might actually prevent playback if the video element is smaller. In a perfect world I would like to give a suggested or target resolution where shaka can for example decide to use a larger version if the screen is around 1000px in height, it could choose 1080p. |
If you use @EyMaddis, in your example, if |
Have you read the FAQ and checked for duplicate open issues?
This was discussed as a part of #565, but the limit based on video container size wasn't implemented.
Is your feature request related to a problem? Please describe.
A functionality that Dash.js and hls.js have is the ability to limit which quality levels are selected based on video element size.
Describe the solution you'd like
On the ABR settings, an extra flag could be added to instruct the ABR manager to limit the quality level based on the video element. For example:
Or:
Those are the options used in Dash.js and hls.js. You can choose any name fits for this project.
Describe alternatives you've considered
Without this feature, a possible solution would be to introduce a
ResizeObserver
on the video element to react to changes in size and dynamically set the ABR restrictions on Shaka player.Additional context
This would allow saving time (and potential problems with the orchestration of the
ResizeObserver
and the dynamic setting of restrictions) that can arise in the implementation of a video player that handles bandwidth in a smart way not to load a video quality that is higher than required at a given moment.The text was updated successfully, but these errors were encountered: