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

feat: Custom Pixel Ratio #1497

Merged
merged 3 commits into from
Mar 8, 2024
Merged

feat: Custom Pixel Ratio #1497

merged 3 commits into from
Mar 8, 2024

Conversation

wseymour15
Copy link
Contributor

@wseymour15 wseymour15 commented Mar 7, 2024

Description

An optional customPixelRatio parameter. This enables the ABR algorithm to act as if the player dimensions were multiplied by a number greater than 0. The benefits of this are to manipulate the player to select higher renditions if better quality video is required, or lower renditions if it is desired to save on bandwidth.

Example:
if you have a player where the dimension is 540p, with a custom pixel ratio of 2, a rendition of 1080p or a lower rendition closest to this value will be chosen.

Specific Changes proposed

  • Expect an optional customPixelRatio option.
  • Multiply the pixelRatio used in our ABR by this value.
  • Tests regarding rendition selection
  • Documentation

Requirements Checklist

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

@wseymour15 wseymour15 self-assigned this Mar 7, 2024
@wseymour15 wseymour15 marked this pull request as draft March 7, 2024 20:56
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.27%. Comparing base (c50ba7e) to head (bce68d9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1497   +/-   ##
=======================================
  Coverage   86.26%   86.27%           
=======================================
  Files          43       43           
  Lines       10877    10884    +7     
  Branches     2501     2504    +3     
=======================================
+ Hits         9383     9390    +7     
  Misses       1494     1494           

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

@wseymour15 wseymour15 marked this pull request as ready for review March 7, 2024 21:02
const pixelRatio = this.useDevicePixelRatio ? window.devicePixelRatio || 1 : 1;
let pixelRatio = this.useDevicePixelRatio ? window.devicePixelRatio || 1 : 1;

pixelRatio = pixelRatio * this.customPixelRatio;
Copy link
Member

@gkatsev gkatsev Mar 7, 2024

Choose a reason for hiding this comment

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

shouldn't this use the customPixelRatio directly, unconditionally? That way, there won't be double counting if both useDevicePixelRatio and customPixelRatio are set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems like a fairly rare case, but worth mentioning. I figured that if someone set both useDevicePixelRatio = true and customPixelRatio = 2, we would want the final pixel ratio to be cumulative. I could see the case where someone would want to save bandwidth or force higher renditions on top of whatever the device pixel ratio is.

Let me know if this seems wrong, but I do agree with @mister-ben that I can document this better.

Copy link
Member

Choose a reason for hiding this comment

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

To me, only using the customPixelRatio seems like a simpler and more straight forward direction. "If it's set, we're going to use this value".
Completely sidesteps needing to worry about the compounding effect. And if someone wanted to do so, they could set it themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, I do not feel strongly either way. I made updates so we overwrite any previous pixel ratio with this value 👍

@mister-ben
Copy link
Contributor

It might be good to explain in the docs how it works when useDevicePixelRatio is also set. It looks like they're cumulative.

@dzianis-dashkevich
Copy link
Contributor

@wseymour15, great work!

@wseymour15 wseymour15 merged commit 0e9d9d8 into main Mar 8, 2024
15 checks passed
@wseymour15 wseymour15 deleted the feat/custom-pixel-ratio branch March 8, 2024 17:12
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.

5 participants