media icon indicating copy to clipboard operation
media copied to clipboard

Setting viewport size does not constrain video resolution as expected

Open cdongieux opened this issue 1 year ago • 2 comments

Version

Media3 1.2.0

More version details

main branch

Devices that reproduce the issue

Any device or emulator

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. In demo app, set viewport size in PlayerActivity.onCreate()
      trackSelectionParameters = new TrackSelectionParameters.Builder(/* context= */ this)
          .setViewportSize(1000, 530, false)
          .build();
  1. Launch demo app
  2. Play item in "Clear DASH" > "HD (MP4, H264)"

Expected result

Max played resolution is 854x380, as the viewport size is set to 1000x530

Actual result

Max played resolution is 1280x570, which exceeds viewport size.

Media

"Clear DASH" > "HD (MP4, H264)" in demo app

Bug Report

  • [ ] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

cdongieux avatar Jun 04 '24 12:06 cdongieux

Hi @cdongieux,

Thanks for reporting! In fact, we intentionally allow one variant above the setViewportSize to be selected. Please refer to https://github.com/google/ExoPlayer/issues/2624#issuecomment-290043466 for the reasons why we do that.

If you really want to restrict the resolution under the specific size, you may want to use the setMaxVideoSize. And in an extreme case that there is no selection can be made based on your restriction, you may want to use setExceedVideoConstraintsIfNecessary to determine whether to allow the track selector exceeds the video constraints or keep no selection.

Hope the above helps!

tianyif avatar Jun 04 '24 18:06 tianyif

Hi @tianyif

Thank you for your answer. The observed behavior is quite surprising though:

  • There is no documentation explaining this intention,
  • There is no documentation about this behavior in setViewportSize
  • Documentation in setViewportSize is counterintuitive: "so that only tracks suitable for the viewport are selected"
  • Documentation in maxVideoWidth precisely says to use setViewportSize for this usecase.

Given that, would you agree to enhance documentation about it?

About the reasons here, it would be great if the API allowed to finely tune variants selection. Something like:

  • set how much a variant can subceed or exceed the viewport size
  • or maybe add a function TrackSelectionParameters.Builder.setVariantsSelectionForViewportSize(<function lambda>)

What's your opinion?

Best regards

cdongieux avatar Jun 05 '24 12:06 cdongieux