ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

HLS selects variant with resolution higher than that of the screen

Open slezadav opened this issue 9 years ago • 2 comments

Issue description

Hls playback changes variant to RESOLUTION=1920x1080 even if the device screen has smaller resolution. Method player.getVideoFormat().getFrameworkMediaFormatV16().getInteger("height") returns 1080. Only specific devices : When the playback changes from 720p to 1080p device gets completely stuck and needs a restart.

Reproduction steps

  1. device with low enough screen resolution.

  2. set the initial bandwidth for playback to be higher than the 720p requirement by hls manifest. my case : #EXT-X-STREAM-INF:PROGRAM-ID=10023275,BANDWIDTH=2400000,RESOLUTION=1280x720 #EXT-X-STREAM-INF:PROGRAM-ID=10023275,BANDWIDTH=4400000,RESOLUTION=1920x1080 int initialBandwidth = 2500000; new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter(), initialBandwidth, AdaptiveTrackSelection.DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS, AdaptiveTrackSelection.DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS, AdaptiveTrackSelection.DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS, AdaptiveTrackSelection.DEFAULT_BANDWIDTH_FRACTION);

  3. wait until the variant incorrectly changes to the resolution above screen resolution. At this point some devices get completely stuck eg. Huawei p8 lite ALE-L21.

Link to test content

https://v22-a.sdn.szn.cz/v_22/vmd_10023275/1481275550?fl=mdk,44257b33|hls2,3,VOD,0

Version of ExoPlayer being used

r2.3.1

Device(s) and version(s) of Android being used

Huawei p8 lite ALE-L21, Android 5.0.1 Samsung GT-I919, Android 4.4.2

A full bug report captured from the device

bugreport.txt

slezadav avatar Mar 29 '17 08:03 slezadav

We do filter out variants that devices claim they're unable to support. If a device is getting stuck it's likely reporting its capabilities to us incorrectly.

To the more general point, I don't think it's incorrect for us to adapt to a resolution higher than that of the display. ExoPlayer doesn't know how you're rendering the video. Some examples where it's more complicated than that:

  • If you're doing something like 360 video where only part of the video is actually shown at any given time, then you probably want the video resolution to be significantly greater than that of the display.
  • In the opposite direction, if you're only showing the video in a small window on the screen, you could argue we shouldn't adapt to resolutions beyond just that window.
  • Even for the standard fullscreen case, if we have one variant significantly below the display resolution and another variant significantly above it, you would probably want to choose the higher one given the choice, if the device supports it.

The above aside, you can tell DefaultTrackSelector to enforce limits of the video size if that's the behaviour you want. Try:

Parameters params = defaultTrackSelector.getParameters();
Parameters newParams = params.withXXX().withXXX()...;
defaultTrackSelector.setParameters(newParams);

The relevant parameters methods are setMaxVideoSize (sets a maximum resolution), withViewportSize (takes a more nuanced approach, allowing one variant above the specified size to be selected, plus considers things like potential screen orientation changes) and withViewportSizeFromContext (ditto assuming the viewport is fullscreen on the primary display).

ojw28 avatar Mar 29 '17 10:03 ojw28

Thank you, setting the params according to your response helped a lot, now it works as I want it to.

slezadav avatar Mar 29 '17 12:03 slezadav