Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant play encrypted video with clearkey drm scheme in Exoplayer2 #9169

Closed
grovertb opened this issue Jul 9, 2021 · 3 comments
Closed

Cant play encrypted video with clearkey drm scheme in Exoplayer2 #9169

grovertb opened this issue Jul 9, 2021 · 3 comments
Assignees

Comments

@grovertb
Copy link

grovertb commented Jul 9, 2021

Hi, I'm having trouble playing an .mpd file with DRM (ClearKey).

This code snippet works for me in my web environment.

var player = new Clappr.Player({
  parentId: '#player',
  autoPlay: true,
  plugins: [DashShakaPlayback],
  source: 'http://localhost:8080/live/manifest.mpd',
  shakaConfiguration: {
    drm: {
      clearKeys: {
        '2f49373e9a10d42964a79530e148ac19': 'fd38b9616945021315f376c5a1b9e7c0'
      }
    }
  },
  height: 360,
  width: 640
})

kid => 2f49373e9a10d42964a79530e148ac19
kid Base64Url => L0k3PpoQ1Clkp5Uw4UisGQ
k => fd38b9616945021315f376c5a1b9e7c0
k Base64Url => /Ti5YWlFAhMV83bFobnnwA

I replaced / by _ as indicated in the documentation https://www.w3.org/TR/encrypted-media/#using-base64url

String keyString = "{\"keys\":[{\"kty\":\"oct\",\"k\":\"_Ti5YWlFAhMV83bFobnnwA\",\"kid\":\"L0k3PpoQ1Clkp5Uw4UisGQ\"}],\"type\":\"temporary\"}";
MediaDrmCallback drmCallback = new LocalMediaDrmCallback(keyString.getBytes());
                        DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder()
                                .setMultiSession(true)
                                .setUuidAndExoMediaDrmProvider(Assertions.checkNotNull(Util.getDrmUuid("clearkey")), FrameworkMediaDrm.DEFAULT_PROVIDER)
                                .build(drmCallback);
                                
mediaSource = new DashMediaSource.Factory(dataSourceFactory).setDrmSessionManager(drmSessionManager).createMediaSource(MediaItem.fromUri(urlStream));

I have tried different ways but cannot reproduce the live one.
I hope you can help me with some solution. Thank you!

Issues:
#3856
#3201
#3138

Note: In the player it shows me this way

Screenshot_20210709-004447_PlayerGO

@icbaker
Copy link
Collaborator

icbaker commented Jul 9, 2021

There isn't enough info here to identify what might be the problem.

Please provide a link to media we can use to reproduce the problem. 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.

@grovertb
Copy link
Author

grovertb commented Jul 9, 2021

There isn't enough info here to identify what might be the problem.

Please provide a link to media we can use to reproduce the problem. 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.

Hi @icbaker, I just sent the mail. Thanks for your answer.

@icbaker
Copy link
Collaborator

icbaker commented Jul 12, 2021

I can reproduce that playback doesn't succeed.

I see this in logcat in the demo app:

tracks [eventTime=2.23, mediaPos=42.03, window=0, period=0
  MediaCodecVideoRenderer [
    Group:0, adaptive_supported=YES [
      [ ] Track:0, id=1621577614203item-01item, mimeType=video/avc, bitrate=300000, codecs=avc1.640029, drm=[playready,widevine], res=366x206, fps=29.97003, supported=NO_UNSUPPORTED_DRM
      [ ] Track:1, id=1621577614203item-02item, mimeType=video/avc, bitrate=900000, codecs=avc1.640029, drm=[playready,widevine], res=544x306, fps=29.97003, supported=NO_UNSUPPORTED_DRM
      [ ] Track:2, id=1621577614203item-03item, mimeType=video/avc, bitrate=1200000, codecs=avc1.640029, drm=[playready,widevine], res=686x386, fps=29.97003, supported=NO_UNSUPPORTED_DRM
      [ ] Track:3, id=1621577614203item-04item, mimeType=video/avc, bitrate=1800000, codecs=avc1.640029, drm=[playready,widevine], res=832x468, fps=29.97003, supported=NO_UNSUPPORTED_DRM
      [ ] Track:4, id=1621577614203item-05item, mimeType=video/avc, bitrate=2500000, codecs=avc1.640029, drm=[playready,widevine], res=1280x720, fps=29.97003, supported=NO_UNSUPPORTED_DRM
      [ ] Track:5, id=1621577614203item-06item, mimeType=video/avc, bitrate=3500000, codecs=avc1.640029, drm=[playready,widevine], res=1920x1080, fps=29.97003, supported=NO_UNSUPPORTED_DRM
    ]
  ]
  MediaCodecAudioRenderer [
    Group:0, adaptive_supported=N/A [
      [ ] Track:0, id=1621577614203item-07item, mimeType=audio/mp4a-latm, bitrate=96000, codecs=mp4a.40.2, drm=[playready,widevine], sample_rate=48000, language=es, supported=NO_UNSUPPORTED_DRM
    ]
  ]
  TextRenderer []
  MetadataRenderer []
  CameraMotionRenderer []
]

Note the drm=[playready,widevine] lines, which should also include cenc if ExoPlayer was able to parse the <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"></ContentProtection> node from your MPD file. This is the info needed for clearkey encryption.

The reason ExoPlayer is unable to parse this is because it's missing a default_KID attribute as required by the DASH-IF guidelines:

The cenc:default_KID attribute SHALL be present and have a value matching the default_KID in the tenc box.

@icbaker icbaker closed this as completed Jul 22, 2021
@google google locked and limited conversation to collaborators Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants