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 calculate bandwidth by using Chromium's networkInfo API #1218

Merged
merged 9 commits into from
Nov 8, 2021

Conversation

evanfarina
Copy link
Contributor

Description

We've found that the player's bandwidth estimations provide lower-than-expected values when a particular segment is encoded with a low bitrate relative to other segments in its lane. This is a fairly common phenomenon when a live stream is using a variable bitrate encoding strategy and is broadcasting a static scene (e.g a slide in a slideshow). We believe that this issue is further exacerbated by two factors:

  1. Segment size - Vhs estimates bandwidth by measuring how many bits were downloaded in a segment and how long, in seconds, it took to download those bits. This estimate factors in network-layer overhead which means that as the number of bits in a segment decreases (either due to bitrate or segment size), the impact that network overhead has on the bandwidth estimate increases
  2. Bandwidth Variance config - Vhs uses a BANDWIDTH_VARIANCE value as a multiplier for the advertised bandwidth value in each lane. The filter calculation looks like lane bandwidth * bandwidth variance < calculatedBandwidth. When calculatedBandwidth is low due to aforementioned reasons, the bandwidth variance default makes it more likely that higher-quality lanes will be filtered out by the player

Specific Changes proposed

Introduce an experimental option that allows the player to leverage Chromium's NetworkInfo.downlink API to estimate bandwidth. Note: This API is not available in Firefox or Safari. When enabled, the player will take the max value between its own bandwidth estimation and that provided by NetworkInformation.downlink.

Please see attached screenshots which demonstrate how the player now selects the higher-quality rendition during static scenes. This demo uses 2-second segments.

Screen Shot 2021-10-29 at 2 34 06 PM

Screen Shot 2021-10-29 at 2 33 27 PM

Screen Shot 2021-10-29 at 2 05 13 PM

Screen Shot 2021-10-29 at 2 32 46 PM

## Requirements Checklist - [x] Feature implemented / Bug fixed - [ ] If necessary, more likely in a feature request than a bug fix - [ ] Unit Tests updated or fixed - [ ] Docs/guides updated - [ ] Example created ([starter template on JSBin](https://jsbin.com/gejugat/edit?html,output)) - [ ] Reviewed by Two Core Contributors

@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #1218 (8334564) into main (25c33ca) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1218      +/-   ##
==========================================
+ Coverage   86.42%   86.43%   +0.01%     
==========================================
  Files          39       39              
  Lines        9743     9752       +9     
  Branches     2263     2267       +4     
==========================================
+ Hits         8420     8429       +9     
  Misses       1323     1323              
Impacted Files Coverage Δ
src/videojs-http-streaming.js 90.78% <100.00%> (+0.19%) ⬆️

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 25c33ca...8334564. Read the comment docs.

src/videojs-http-streaming.js Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
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.

Thank you for the PR @evanfarina ! A few comments for consideration.

index.html Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
test/videojs-http-streaming.test.js Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

It's nice that it's pretty simple and self-contained!

index.html Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/videojs-http-streaming.js Outdated Show resolved Hide resolved
@gkatsev gkatsev merged commit 061cf3c into videojs:main Nov 8, 2021
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