UnityPlugin-AVProVideo
UnityPlugin-AVProVideo copied to clipboard
Dynamically change adaptive resolution settings on Android
Describe the issue Android adaptive resolution & bitrate does not work. The iOS adaptive resolution & bitrate works well.
Your Setup:
- Unity version: 2021.1.21f1 & 2020.3.19f1 LTS
- AVPro Video version: 2.2.1 ultra build 815, Ultra Paid version.
- Operating system version: MacOS 11.6
- Device model: Samsung S8, SM-G950F, Android 9
- Video specs (resolution, frame-rate, codec, file size): HLS Multibitrate, 30fps, H.264, 240x240 up to 3860x3860, see HLS URL.
To Reproduce
-
Setup Player with:
// ANDROID Start adaptive stream using the lowset resolution - ExoPlayer only
player.PlatformOptionsAndroid.videoApi = Android.VideoApi.ExoPlayer;
player.PlatformOptionsAndroid.startWithHighestBitrate = false;
player.PlatformOptionsAndroid.minBufferMs = 2000;
player.PlatformOptionsAndroid.maxBufferMs = 5000;
player.PlatformOptionsAndroid.bufferForPlaybackMs = 2000;
player.PlatformOptionsAndroid.bufferForPlaybackAfterRebufferMs = 4000;
player.PlatformOptionsAndroid.preferredMaximumResolution = OptionsAndroid.Resolution.NoPreference;
player.PlatformOptionsAndroid.preferredPeakBitRate = 40.0f;
player.PlatformOptionsAndroid.preferredPeakBitRateUnits = OptionsAndroid.BitRateUnits.Mbps;
-
Start Player with source: https://gms001.s3.ap-southeast-2.amazonaws.com/video/hls/360/iiv/001/source/source_03/playlist.m3u8
-
When playing Set Params:
player.PlatformOptionsAndroid.preferredMaximumResolution = OptionsAndroid.Resolution.NoPreference;
player.PlatformOptionsAndroid.preferredPeakBitRate = 40.0f;
player.PlatformOptionsAndroid.preferredPeakBitRateUnits = OptionsAndroid.BitRateUnits.Mbps;
OR
player.PlatformOptionsAndroid.preferredMaximumResolution = OptionsAndroid.Resolution._480p;
player.PlatformOptionsAndroid.preferredPeakBitRate = 0.1f;
player.PlatformOptionsAndroid.preferredPeakBitRateUnits = OptionsAndroid.BitRateUnits.Mbps;
Anyone is looking at this issue? We bought this new Ultra Edition hoping we have High Support Priority.
Thanks for submitting this issue. Could you explain what you mean by "does not work"?
Adaptive HLS should certainly work on both platforms.
As for adjusting the parameters once playback has started, currently Android doesn't support this, so these settings:
player.PlatformOptionsAndroid.preferredMaximumResolution
player.PlatformOptionsAndroid.preferredPeakBitRate
player.PlatformOptionsAndroid.preferredPeakBitRateUnits
are only applied during loading. This is something we could look into. Is this the issue you're referring to?
Thanks,
Hi AndrewRH, Yes, we need to be able to switch adaptive resolution & bitrate, while already in playback, the same as currently iOS works. This is very important for us.
This may not be possible but I will investigate
Dynamically changing adaptive resolution or Dynamically changing PeakBitrate it's very important for us. We have previously purchased the Video edition and now purchased the Ultra Edition. We also considering purchasing the Enterprise Edition (depending it has the features we need. )
I think I have found a way this can be achieved on Android. The (possible) problem is...that I think that when you set the preferred resolution/bitrate to something new...you will get a hard 'cut' down to a stream that fits the new parameters better.
I will continue to investigate if there is a smoother way for this to happen - playing out current prepared chunks before the switch.
Great, can't wait to see the results. At the end of the day, it works for the iOS player, so we have something to compare it with.
Word of warning. We will unlikely be able able to match Android to iOS exactly.
Currently looking at an option that would allow seamless transitions. Downside is that the switch will only happen when the current downloaded buffer has been exhausted. Lowering the buffer values should allow for quicker switching. However, those values are not changeable on the fly. Currently this is not working due to something odd happening in ExoPlayer that I do not fully understand yet.
We'd be interested in being able to set the maximum resolution for the HLS ladder on Android as well, although we don't need it during playback, as simply being able to change it before playing a new video would be fine. In my testing so far, it seems like maximum resolution only is used if it's set before the AndroidMediaPlayer constructor runs.