ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Player event when rendered bitrate changes

Open marklynk opened this issue 5 years ago • 4 comments

Hello,

Is there an event I can hook into to determine when the currently rendered bitrate changes? I saw you can calculate average bitrate

Log.d("DEBUG", "Additional calculated summary metrics: "
    + "average video bitrate = " + playbackStats.getMeanVideoFormatBitrate()

but did not find something for the current rendered bitrate. Thanks!

marklynk avatar Aug 31 '21 13:08 marklynk

Can you clarify exactly what you mean by "when the currently rendered bitrate changes"? Do you mean "when the current media file changes and it has a different average bitrate than the previous one"? Or "when the compressed bitrate of the video frame being renderered changes"? Or anything else?

kim-vde avatar Sep 01 '21 17:09 kim-vde

Basically we want to know when the player switches to a different rendition due to network bandwidth change and when it does, what is the bitrate of the video being rendered

marklynk avatar Sep 01 '21 17:09 marklynk

what is the bitrate of the video being rendered

Sounds like AnalyticsListener.onVideoInputFormatChanged() is what you are looking for. The AnalyticsListener has other methods like onVideoSizeChanged(), but I think the Format can change for the video size or the frame rate when changing tracks. The Format gives you both.

Basically we want to know when the player switches to a different rendition

The actual notification that an adaptive track change has occurred is notified with AnalyticsListener.onTracksChanged(). You could extract the information from the track selection as well.

due to network bandwidth change

I think strictly speaking you can't know the reason for the change of video size or tracks from the listener being called alone. This can be a decision taken by the adaptive track selector based on network bandwidth change. Other things like load errors or manual track selection can cause the same listeners methods to be called.

You can also use EventLogger as a start and inspect the logs when you play. That will give you a good feeling of what listener method is best for your use case.

marcbaechinger avatar Sep 03 '21 10:09 marcbaechinger

Closing due to inactivity.

marcbaechinger avatar Dec 28 '21 12:12 marcbaechinger