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

Support for maximum bit rate adaptive streaming #1310

Merged

Conversation

ashnfb
Copy link
Contributor

@ashnfb ashnfb commented Oct 29, 2018

iOS and Android support maximum bit rates for HLS streams; and this can be helpful when a user wants to limit bandwidth consumption (example may include limiting content on cellular devices).

This PR implements this prop for both platforms

Example to test:

specify adaptive streaming without maximum bitrate limit (this is default when prop not specified)
maximumBitRate={0}

specify adaptive streaming with maximum bitrate limit
maximumBitRate={2500000}

[2500000 is an example medium-quality encoded 720P h264 video, but it will vary by the encoder and source]

@cobarx
Copy link
Contributor

cobarx commented Nov 5, 2018

Hi @ashnfb, great feature.

I went ahead and made some updates to the documentation and code. I've renamed it to maxBitRate to keep it in the style of bufferConfig.

In the docs, I made a couple of changes:

  • Added a link to the maxBitRate entry in the list of props
  • Added platform support info
  • Removed note that this is for HLS streams. On ExoPlayer, this will work on DASH streams with multiple video profiles as well
    It's critical we document these correctly, as someone reading the docs will be looking to them to understand the capabilities of the feature.

Looking at the iOS code, if you set the maxBitRate after the video is loaded, nothing will happen because there is nothing in applyModifiers to apply it. This is a pretty common use case if you want to emulate YouTube and change the bitrate mid-playback. Please update the PR to handle it.

Otherwise looking very good. I am going to wait for the change and will test then. Do you by any chance have a sample stream I can use to test?

@ashnfb ashnfb force-pushed the maximumBitRate-adaptive-streaming branch from 468491d to 12a482a Compare November 26, 2018 18:35
@ashnfb
Copy link
Contributor Author

ashnfb commented Nov 26, 2018

Hi @cobarx, support for applyModifiers and maxBitRate.
Btw, you had updated the readme to specify maxBitRate, however the code was still maximumBitRate. That's fixed ;)

@c1ngular
Copy link

c1ngular commented Dec 7, 2018

it is possible to make video player to automatically switch between different bitrates/resolutions according to current internet connection speed/quality at real time ?

@ashnfb
Copy link
Contributor Author

ashnfb commented Dec 10, 2018

@c1ngular, the code permits chaining the maximum bitrates; however two caveats:

  1. on iOS, it's not clear whether Apple supports changing bandwidth during playback
  2. I don't think is the responsibility of react-native-video to make decisions about internet connection and accordingly change bitrate. In my project, we do that in our own codebase.

@c1ngular
Copy link

@ashnfb thanks !

@cobarx
Copy link
Contributor

cobarx commented Dec 13, 2018

@c1ngular The underlying player will automatically change bitrates to what it feels is the appropriate stream/resolution. I believe there is a PR in the works to support choosing a specific resolution similar to what YouTube offers.

@cobarx cobarx changed the title Support for HLS maximum bit rate adaptive streaming Support for maximum bit rate adaptive streaming Dec 13, 2018
@cobarx
Copy link
Contributor

cobarx commented Dec 13, 2018

@ashnfb Tested this on iOS tonight and it's looking good. I'll get to ExoPlayer tomorrow and merge it! Thanks for making the changes.

@cobarx
Copy link
Contributor

cobarx commented Dec 13, 2018

@ashnfb It just occurred to me that we should document how to clear the value by setting it to zero. If you get to it before I review tomorrow, can you add a note about that.

Also, looking at the Android code you are setting max rate to 0 when initializing the video. That's not what we want since it wants MaxInfinity to indicate auto-selection, I'd imagine it will cause it to select the minimum bitrate stream. I would instead use a conditional like this:

            trackSelector.setParameters(trackSelector.buildUponParameters()
                            .setMaxVideoBitrate(maxBitRate === 0 ? Integer.MAX_VALUE : maxBitRate));

@ashnfb
Copy link
Contributor Author

ashnfb commented Dec 13, 2018

@cobarx thanks for making the changes

@cobarx
Copy link
Contributor

cobarx commented Dec 13, 2018

@ashnfb No problem, I didn't see your message till just now. Have a little time this morning to do open source work, so I hopped right into it.

@cobarx cobarx merged commit 62f7221 into TheWidlarzGroup:master Dec 13, 2018
@ivanzhang
Copy link

@cobarx i getting build error in android ...
image

beauner69 pushed a commit to beauner69/react-native-video that referenced this pull request Oct 10, 2019
…daptive-streaming

Support for maximum bit rate adaptive streaming

(rebased from commit 62f7221)
@coucoseth
Copy link

@c1ngular The underlying player will automatically change bitrates to what it feels is the appropriate stream/resolution. I believe there is a PR in the works to support choosing a specific resolution similar to what YouTube offers.

Was this feature worked on, if yes, how can i activate/implement

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