ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Question:How to set max bit rate in exoplayer v2

Open jiafei1986 opened this issue 9 years ago • 6 comments

I am now doing the video app of dash, there is a requirement to let the user choose video quality there are 4 types (auto, high, medium,low), the high, medium,low will be configed in the backend.

I know there is a method in v1 DashRendererBuilder.setMaxBitrate(maxBitrate); but is there an easy way to set it in v2? Thanks.

jiafei1986 avatar Jul 13 '17 15:07 jiafei1986

We centralized everything to do with track selection in V2. Assuming you have a DefaultTrackSelector somewhere, you can set the maximum bitrate with:

trackSelector.setParameters(
    trackSelector.getParameters().withMaxVideoBitrate(maxBitrate));

You should do this before calling player.prepare if you want this to affect the initial track selection.

ojw28 avatar Jul 13 '17 16:07 ojw28

@ojw28 Thanks for your answer. so you mean it will not affect when the user changes the quality during the playback? is it a way to change it during playback?

jiafei1986 avatar Jul 14 '17 00:07 jiafei1986

@ojw28 I tested this method, it also affects during playback, thank you very much. Great work!!!

jiafei1986 avatar Jul 14 '17 02:07 jiafei1986

@ojw28 when user select auto, what value should i set to this method? is it 0?

jiafei1986 avatar Jul 29 '17 01:07 jiafei1986

Use Integer.MAX_VALUE :).

ojw28 avatar Jul 31 '17 17:07 ojw28

Hi,

However i set withMaxVideoBitrate value before player.prepare, player still changes video profiles to higher than i set. For example i set 600.000. when i checked current video bitrate after i while i get 3.000.000.

The stream has 500.000,900.000,1.500.000,3.000.000 video formats

    int maxBitrate=600000;
    player.seekToDefaultPosition();
    trackSelector.getParameters().withMaxVideoBitrate(maxBitrate);
    player.prepare(mediaSource, !haveResumePosition, false);

erenbakac avatar Oct 12 '17 13:10 erenbakac