google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

Auto Adaptive Streaming of video bit-rate in Exoplayer (Stuck in lowest resolution) using drm #9442

Closed neeluagrawal04 closed 3 years ago

neeluagrawal04 commented 3 years ago

Using DRM supported urls in .mpd format streaming of video in auto mode willl stuck in low quality resolution

icbaker commented 3 years ago

Please provide media links and DRM license info we can use to reproduce the problem in the ExoPlayer demo app.

Please either upload it here or send to dev.exoplayer@gmail.com using a subject in the format Issue #1234 (where #1234 should be replaced with this issue number.) Please also update this issue to indicate you’ve done this.

neeluagrawal04 commented 3 years ago

sample url with the license info is shared on the provided mail id

icbaker commented 3 years ago

Thanks for the stream details - however I'm unsure what do with the base64 (?) string provided for the DRM info. I was expecting a license server URI that I could pass to MediaItem.Builder#setDrmLicenseUri(String).

Could you please explain how you use this string to configure playback in your app?

neeluagrawal04 commented 3 years ago

Thanks for a quick response. Replied on a separate mail thread for your reference and provided the details in the same.

icbaker commented 3 years ago

Thank you - I'm able to play the video with the information provided.

I noticed that there are 3 video representations in the DASH manifest with 3 different resolutions but the same bitrate:

<Representation id="1" width="320" height="180" bandwidth="150000" codecs="avc1.4d400d">
  <SegmentTemplate media="redacted" initialization="redacted" duration="1080000" startNumber="1"/>
</Representation>
<Representation id="2" width="400" height="224" bandwidth="150000" codecs="avc1.4d400d">
  <SegmentTemplate media="redacted" initialization="redacted" duration="1080000" startNumber="1"/>
</Representation>
<Representation id="3" width="720" height="404" bandwidth="150000" codecs="avc1.4d401e">
  <SegmentTemplate media="redacted" initialization="redacted" duration="1080000" startNumber="1"/>
</Representation>

And the ExoPlayer demo app reports the same info via its debug logging:

tracks [eventTime=0.97, mediaPos=0.00, window=0, period=0
  MediaCodecVideoRenderer [
    Group:0, adaptive_supported=YES [
      [X] Track:0, id=1, mimeType=video/avc, bitrate=150000, codecs=avc1.4d400d, drm=[playready,widevine,cenc], res=320x180, fps=30.0, supported=YES
      [X] Track:1, id=2, mimeType=video/avc, bitrate=150000, codecs=avc1.4d400d, drm=[playready,widevine,cenc], res=400x224, fps=30.0, supported=YES
      [X] Track:2, id=3, mimeType=video/avc, bitrate=150000, codecs=avc1.4d401e, drm=[playready,widevine,cenc], res=720x404, fps=30.0, supported=YES
    ]
  ]
  MediaCodecAudioRenderer [
    Group:0, adaptive_supported=N/A [
      [X] Track:0, id=4, mimeType=audio/mp4a-latm, bitrate=96000, codecs=mp4a.40.2, drm=[playready,widevine,cenc], sample_rate=48000, language=und, supported=YES
    ]
  ]
  TextRenderer []
  MetadataRenderer []
  CameraMotionRenderer []
]

I downloaded a couple of segments of different representations from your stream and found that the 320x180 segment (95kB including init segment) had an 'actual' overall bitrate (i.e. file size / duration) of more like 65kbps while the 720x404 file (218kB including init segment) had an actual bitrate of 149kbps.

So I think your media is reporting incorrect bitrate information - and therefore it seems to you that ExoPlayer is making surprising track selection decisions. If you fix the media (I suspect both the init segments and the manifest need to be fixed) then ExoPlayer's default behaviour will be to select the highest bitrate track that fits into the available network bandwidth.

navjotbedi commented 3 years ago

@icbaker I work along with @neeluagrawal04 and thank you for sharing the issue. We are facing one more issue with DRM.

Issue: While playing the above online video, DRM License URL is making a new network call every time the video is played. This is costing us a number of licenses generation.

Expectation: DRM License URL should provide the license one time (till 30days) as we have configured the DRM auth XML for 30days.

Snippet: This is how we are generating the Media Item

val mediaItem = MediaItem.Builder().setUri(MEDIA_URL).setMediaMetadata(MediaMetadata.Builder().setTitle("Test Media").build()).setDrmUuid(UUID.fromString(UUIDString)).setDrmLicenseUri(LICENSE_URL).setDrmLicenseRequestHeaders(headers).build()

UUIDString - Constant String Always LICENSE_URL - DRM License URL headers -> "x-keyos-authorization" :

Stream details for this issue is the same, provided to you by @neeluagrawal04 over email.

Can you please let us know what are we doing wrong? Kindly let us know if you need more information.

icbaker commented 3 years ago

@navjotbedi Please file a new issue