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

Dorska/quality selector #556

Merged
merged 6 commits into from Apr 24, 2018
Merged

Dorska/quality selector #556

merged 6 commits into from Apr 24, 2018

Conversation

adorsk
Copy link
Contributor

@adorsk adorsk commented Apr 19, 2018

What are the relevant tickets?

#377

What's this PR do?

Adds a new control to the VideoPlayer control bar that allows the user to select a video quality setting.

How should this be manually tested?

  1. Ensure that you have a video that's at least a few minutes long. I'm a fan of https://ia802702.us.archive.org/16/items/fireplace/FireplaceGlenLakeMi.11-06-07_512kb.mp4 .
  2. Check that the selected bitrate changes after ten seconds:
    1. Open up dev tools, and activate (1) 'Network Conditions' section and (2) the 'Network' tab.
    2. Start the video playing. you should start to see lines in the Network tab like video_...-2gfh90...ts . The "2gfh90" indicates that the highest bitrate is being used.
    3. Let ten seconds go by, and then in the 'Network Conditions' tab, set 'Network throttling' to a slower value (like 'slow 3G').
    4. Ensure that you see the lines in the 'Network' tab change. Probably to something like video_...-06dkm6...ts.
  3. Check that the you can set the bitrate.
    1. Reload the page, and start the video playing again.
    2. Let ten seconds go by.
    3. Now click the 'HD' button in the video player controls and select a value.
    4. Ensure that the 'Network' tab shows different .ts lines.
    5. Ensure that different selections in the menu result in different .ts lines.
  4. Check that the auto bitrate works.
    1. Reload the page, and start the video playing again.
    2. Let ten seconds go by.
    3. Now click the 'HD' button in the video player controls and select a value.
    4. Then select the 'auto' value.
    5. Let ten seconds go by, and then in the 'Network Conditions' tab, set 'Network throttling' to a slower value (like 'slow 3G').
    6. Ensure that you see different .ts lines.
    7. Disable the 'Network throttling', and ensure that you see different .ts lines.

Any background context you want to provide?

Normally videojs adaptively determines which bitrate to use, per:
https://github.com/videojs/videojs-contrib-hls/blob/master/docs/bitrate-switching.md
We can override the normal behavior by toggling active bitrates. The videojs-contrib-quality-levels plugin provides an API for doing this toggling.
And in this PR we add a control that allows humans to interact with that API.

@adorsk adorsk requested a review from mbertrand April 19, 2018 14:48
@codecov-io
Copy link

codecov-io commented Apr 19, 2018

Codecov Report

Merging #556 into master will decrease coverage by 0.93%.
The diff coverage is 35.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #556      +/-   ##
==========================================
- Coverage    95.9%   94.96%   -0.94%     
==========================================
  Files         151      152       +1     
  Lines        5465     5542      +77     
  Branches      220      220              
==========================================
+ Hits         5241     5263      +22     
- Misses        189      244      +55     
  Partials       35       35
Impacted Files Coverage Δ
webpack.config.shared.js 100% <ø> (ø) ⬆️
static/js/lib/video.js 96.55% <100%> (+0.39%) ⬆️
static/js/components/VideoPlayer_test.js 99.5% <100%> (+0.04%) ⬆️
static/js/components/VideoPlayer.js 93.5% <100%> (+0.04%) ⬆️
static/js/lib/videojs_hls_quality_selector.js 3.5% <3.5%> (ø)

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 39dca4b...4fdb76f. Read the comment docs.

@pdpinch
Copy link
Member

pdpinch commented Apr 23, 2018

@adorsk if this is ready for review, can you add the "Needs Review" label? That's our most reliable signal that a PR is ready.

@mbertrand mbertrand self-assigned this Apr 23, 2018
requirements.txt Outdated
-e git+https://github.com/mitodl/django-elastic-transcoder.git#egg=django-elastic-transcoder
-e git+https://github.com/Brown-University-Library/django-shibboleth-remoteuser.git#egg=django-shibboleth-remoteuser
-e git+https://github.com/mitodl/mit-moira.git#egg=mit-moira
-e git+https://github.com/mitodl/pycaption.git#egg=pycaption
Copy link
Member

Choose a reason for hiding this comment

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

Can you revert the changes to this file?

return _.last(playlists)
}
// Return playlist with highest bandwidth <= system bandwidth
Copy link
Member

Choose a reason for hiding this comment

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

This overrides the native HLS algorithm so that the video player's size in the browser is ignored; and should still be used unless someone manually selects a quality level.

@@ -339,7 +337,12 @@ class VideoPlayer extends React.Component<*, void> {
})
})
if (this.tech_.hls !== undefined) {
this.tech_.hls.selectPlaylist = selectPlaylist
const _originalSelectPlaylist = this.tech_.hls.selectPlaylist
Copy link
Member

Choose a reason for hiding this comment

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

This was overriden in a previous PR so that the size of the video in the browser is ignored when determining the optimal resolution to play. Can you revert to using that custom algorithm instead of the default one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see what you mean.

Updated to use a modified version of the previous custom algorithm. The modification is: the algorithm will now select the highest active playlist that is less than the available system bandwidth, or the first active playlist if no active playlist is <= system bandwidth.

The quality selector widget sets all non-selected playlists to disabled. If 'auto' is selected it sets all playlists to active.

)
}

selectInitialQualityLevel() {
Copy link
Member

Choose a reason for hiding this comment

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

This function doesn't seem to be used, can it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, nice catch. removed.

@@ -0,0 +1,135 @@
/* Adapted from https://github.com/chrisboustead/videojs-hls-quality-selector .
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to bring in/adapt some of the unit tests for this plugin too, to improve coverage?

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 wasn't sure on whether this would be worth it. The original plugin just tests that it can register against videojs:
https://github.com/chrisboustead/videojs-hls-quality-selector/blob/master/test/plugin.test.js

We could write tests, but I think it would mostly look like a lot of mocking for videojs functions.

Do you think it's worth pursuing? Either way is fine with me.

Copy link
Member

Choose a reason for hiding this comment

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

Ok with me to skip it if it won't add much value.

@adorsk
Copy link
Contributor Author

adorsk commented Apr 24, 2018

@mbertrand reverted requirements.txt to take out -e flags, should work with travis now per bug fix from pip 10.0.1 (pypa/pip#5251).

Ready for review again.

Copy link
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

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

👍

@adorsk adorsk merged commit a109d38 into master Apr 24, 2018
@adorsk adorsk deleted the dorska/quality_selector branch April 24, 2018 17:59
@adorsk
Copy link
Contributor Author

adorsk commented Apr 24, 2018

Closed #377.

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.

None yet

4 participants