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

add an option to ignore player size in selection logic #238

Merged
merged 7 commits into from
Oct 5, 2018

Conversation

theRealWardo
Copy link
Contributor

@theRealWardo theRealWardo commented Sep 21, 2018

Description

Some modern encoding techniques target the best quality at a given bitrate, to some extent irrespective of resolution. In such scenarios, users should be able to tell the player that the player size should be ignored during rendition selection in order to favor a pure bandwidth based decision which will maximize quality for the playback.

Specific Changes proposed

  • add a limitRenditionByPlayerDimensions configuration option which can be set to false to ignore resolutions when doing rendition selection.

Requirements Checklist

  • Feature implemented / Bug fixed - awww yea
  • If necessary, more likely in a feature request than a bug fix
    • Unit Tests updated or fixed - wrote some unit tests!
    • Docs/guides updated - wrote docs in the README
    • Example created - https://jsbin.com/gejugat/4/edit?html,output - I mean this is a pretty boring example as I'm just setting the config variable in it.
  • Reviewed by Two Core Contributors

@welcome
Copy link

welcome bot commented Sep 21, 2018

💖 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.

@@ -217,6 +230,7 @@ export const simpleSelector = function(master,
resolutionPlusOneList = haveResolution.filter(
(rep) => rep.width > playerWidth || rep.height > playerHeight
);
console.log('resolutionPlusOneList', haveResolution, resolutionPlusOneList, playerWidth, playerHeight);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there's logging left over from debugging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep you right. removed it.

@forbesjo
Copy link
Contributor

Seems reasonable to me, @gesinger thoughts?

bandwidthBestRep ||
enabledPlaylistReps[0] ||
sortedPlaylistReps[0]
);
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need a newline here to fix linting errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea so like I got a ton of linting errors relating to exceeds the maximum line length of 90, Don't make functions within a loop and Unexpected "todo" comment so I admittedly ignored all of them and just opened a PR... sorry

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries, when we update our linter I think it should be more clear which of those is a linter error and just a warning

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This is definitely a nice flag to have.

README.md Outdated
* Type: `boolean`
* can be used as an initialization option

When `ignorePlayerSize` is set to true, selection logic will ignore the
Copy link
Contributor

Choose a reason for hiding this comment

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

selection logic => rendition selection logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

README.md Outdated
* can be used as an initialization option

When `ignorePlayerSize` is set to true, selection logic will ignore the
player size and rendition resolutions when making a decision. This should
Copy link
Contributor

Choose a reason for hiding this comment

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

The should part here is a bit unclear to me, but I may not fully understand the scenario. Any more details on that part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am opening this PR because I had a customer using our per-title encoding solution which is marketed at https://mux.com/per-title-encoding/ and described in all kinds of fun technical detail at - https://mux.com/blog/per-title-encoding-scale/ - a specific video was seen to never play anything "reasonably good looking" given the generated rendition set which I put in the unit tests. most people in the industry would look at that ladder and say "what?" so I wrote this comment. but since the comment had a "what?" response, I guess I'll delete it. 😄

README.md Outdated
@@ -333,6 +333,16 @@ When `enableLowInitialPlaylist` is set to true, it will be used to select
the lowest bitrate playlist initially. This helps to decrease playback start time.
This setting is `false` by default.

##### ignorePlayerSize
Copy link
Contributor

Choose a reason for hiding this comment

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

In terms of naming, I think it might be a bit easier to use a positive and have it be true by default. Also maybe a bit more precise for rendition selection. Maybe something like limitRenditionSelectionByPlayerDimensions, though that name could be too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am more than happy to name this anything the maintainers like. just let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with limitRenditionByPlayerDimensions, default to true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe I have updated all of the things!

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

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

Minor comment wording, but otherwise LGTM

src/playlist-selectors.js Outdated Show resolved Hide resolved
@theRealWardo
Copy link
Contributor Author

oo there seems to be something wrong according to the tests... taking a look...

@theRealWardo
Copy link
Contributor Author

maybe something is wrong in the defaults here, despite the unit tests saying they work, I saw a bunch of behavior that indicated that limitRenditionByPlayerDimensions was undefined. not sure what to do here as the tests that were failing in CI never pass on my machine even on master.

@theRealWardo
Copy link
Contributor Author

@forbesjo @gesinger - mind taking one last look and merging this if you are comfortable with it please?

@@ -335,6 +332,7 @@ class HlsHandler extends Component {
setOptions_() {
// defaults
this.options_.withCredentials = this.options_.withCredentials || false;
this.options_.limitRenditionByPlayerDimensions = this.options_.limitRenditionByPlayerDimensions || true;
Copy link
Contributor

@forbesjo forbesjo Sep 26, 2018

Choose a reason for hiding this comment

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

Wont this always be true? In which case this option wont take affect if you set this to false in the player options instead of source options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://media3.giphy.com/media/14aUO0Mf7dWDXW/giphy.gif

@theRealWardo theRealWardo force-pushed the mw-ignore-player-size branch from c2f70e0 to 9b24234 Compare October 2, 2018 15:30
@theRealWardo
Copy link
Contributor Author

patched the silly mistake that @forbesjo found, fix the test that I misconfigured making be believe it was working correctly when it wasn't, and now I think its ready for another look. thanks!!

Copy link
Contributor

@forbesjo forbesjo left a comment

Choose a reason for hiding this comment

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

Looks good to me. @gesinger do you agree?

@@ -261,7 +275,8 @@ export const lastBandwidthSelector = function() {
return simpleSelector(this.playlists.master,
this.systemBandwidth,
parseInt(safeGetComputedStyle(this.tech_.el(), 'width'), 10),
parseInt(safeGetComputedStyle(this.tech_.el(), 'height'), 10));
parseInt(safeGetComputedStyle(this.tech_.el(), 'height'), 10),
this.limitRenditionByPlayerDimensions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below, I don't think this value will ever be set, since limitRenditionByPlayerDimensions is set within the options_ object property and not on the HlsHandler instance directly.

Copy link
Contributor Author

@theRealWardo theRealWardo Oct 2, 2018

Choose a reason for hiding this comment

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

I really should have spent some more time running the code via the debugger to make sure things were getting passed around. I did some more testing using this m3u8 which I created with Mux per title encoding - https://stream.mux.com/d3dYsgwvtxk101D6ExK3HuoKe3aps9IIA.m3u8 - you can pretty clearly spot the difference on the test page when setting limitRenditionByPlayerDimensions: false if you use this manifest.

this is my first PR for this repo so I was all like...

I'm going to update your contribution guidelines with some learnings from this process in another PR

@forbesjo forbesjo merged commit 7ae42b1 into videojs:master Oct 5, 2018
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.

3 participants