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

Exoplayer2 questions about the buffer, format switching. #6607

Closed
VenkateswaraRajuDatla opened this issue Oct 31, 2019 · 5 comments
Closed
Assignees
Labels

Comments

@VenkateswaraRajuDatla
Copy link

VenkateswaraRajuDatla commented Oct 31, 2019

Hi Developers,

  1. Why is this value DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS is 10000 ?
    Link:
    https://exoplayer.dev/doc/reference-v1/constant-values.html#com.google.android.exoplayer.chunk.FormatEvaluator.AdaptiveEvaluator.DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS

  2. What are the effects if we try to decrease the above value to very low in order to avoid the format switching delay (low to high).

  3. How does the buffer manages the low format video chunks already downloaded if it need to switch to higher format ? How the buffer works in downloading the contents?

Anyone please help me in these.
Thanks in advance

@tonihei tonihei self-assigned this Nov 5, 2019
@tonihei
Copy link
Collaborator

tonihei commented Nov 5, 2019

  1. That's a good guess only. It need to be low enough to allow switching up quickly if the conditions allow it, but it also needs to be big enough to ensure we don't run into rebuffers immediately, if upswitching turns out not to be sustainable.

  2. See above. You may get more rebuffers and it's generally more risky.

  3. Switching happens on the loading side of the buffer queue. That is, the decision is always made whenever we need to load a new chunk and no existing buffer is dropped. We have another parameter (minDurationToRetainAfterDiscardMs) that control how many low-quality samples can be dropped to load high-quality content instead.

@VenkateswaraRajuDatla
Copy link
Author

Hi Tonihei,

Thank you so much for the quick response.

I have one more question.

Let's assume
buffer size is 16 sec, each video chunk is 2 sec, Current format is 720P, minDurationForQualityIncreaseMs is 10 sec, Already buffer have 6 video chunks of quality 720P.

Now based on above, the buffered started playing the chunks, at t=4 sec(at the end of 2nd video chunk) the controller detected the higher bandwidth and triggers 1080P.

Now the buffer will play the remaining 720P downloaded video chunks as normal until the end of last (6th) chunk (in time it is 12th sec).
But there is still 2sec delay left to switch to high quality because of the parameter "minDurationForQualityIncreaseMs' which is 10 - (12-4) = 2sec.

For the left 2sec will the buffer try to download 720P video chunk or 1080P video chunk?

Through my tests, I got to know that it is waiting for the condition minDurationForQualityIncreaseMs to be satisfied but I want to know how the buffer is acting in this scenario.

Thanks in advance.

@tonihei
Copy link
Collaborator

tonihei commented Nov 5, 2019

If you have 16 seconds of video buffered and minDurationForQualityIncreaseMs is set to 10 seconds and the current bandwidth estimate is sufficient for switching up, then the next chunk will be loaded in the higher resolution.

@VenkateswaraRajuDatla
Copy link
Author

VenkateswaraRajuDatla commented Nov 5, 2019

Got it and thank you.
Few more questions,

  1. How to know the buffer size in exoplayer?

  2. Also In my exoplayer project,
    In the AdaptiveTrackSelection class, evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue) method is never called.
    Do you have any idea when and where generally it is called?

Somehow I am experiencing a delay of 48 sec during format switching (in both cases).
I made sure that below code is commented to switch the formats soon. But still I had delay of 48 sec.

if (!isBlacklisted(currentSelectedIndex, nowMs)) {
// Revert back to the current selection if conditions are not suitable for switching.
Format currentFormat = getFormat(currentSelectedIndex);
Format selectedFormat = getFormat(selectedIndex);
if (selectedFormat.bitrate > currentFormat.bitrate
&& bufferedDurationUs < minDurationForQualityIncreaseUs(availableDurationUs)) {
// The selected track is a higher quality, but we have insufficient buffer to safely switch
// up. Defer switching up for now.
selectedIndex = currentSelectedIndex;
} else if (selectedFormat.bitrate < currentFormat.bitrate
&& bufferedDurationUs >= maxDurationForQualityDecreaseUs) {
// The selected track is a lower quality, but we have sufficient buffer to defer switching
// down for now.
selectedIndex = currentSelectedIndex;
}

@tonihei
Copy link
Collaborator

tonihei commented Nov 6, 2019

  1. player.getBufferedPosition and player.getTotalBufferedDuration should help. The AdaptiveTrackSelection class gets this information as parameter in the method calls.

  2. This method may not be executed if the MediaSource doesn't support it. If you are using HLS for example, this is currently not supported. See Add support for upstream discard to HLS #6322 that tracks adding this feature.

@tonihei tonihei closed this as completed Dec 10, 2019
@google google locked and limited conversation to collaborators Feb 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants