UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Dynamically change adaptive resolution settings on Android

Open ondevChrisD opened this issue 4 years ago • 11 comments

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

  1. 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;
  1. Start Player with source: https://gms001.s3.ap-southeast-2.amazonaws.com/video/hls/360/iiv/001/source/source_03/playlist.m3u8

  2. 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;

ondevChrisD avatar Oct 15 '21 06:10 ondevChrisD

Anyone is looking at this issue? We bought this new Ultra Edition hoping we have High Support Priority.

ondevChrisD avatar Oct 19 '21 13:10 ondevChrisD

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,

AndrewRH avatar Oct 19 '21 15:10 AndrewRH

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.

ondevChrisD avatar Oct 20 '21 08:10 ondevChrisD

This may not be possible but I will investigate

Ste-RH avatar Nov 01 '21 14:11 Ste-RH

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. )

ondevChrisD avatar Nov 07 '21 12:11 ondevChrisD

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.

Ste-RH avatar Nov 10 '21 15:11 Ste-RH

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.

ondevChrisD avatar Nov 11 '21 05:11 ondevChrisD

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.

Ste-RH avatar Nov 11 '21 12:11 Ste-RH

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.

acgourley avatar Dec 22 '21 02:12 acgourley