ClearKey drm not working in dashjs but shakaplayer ok
Created by: Murmur
I am testing ClearKey drm decryption and the following ShakaPlayer works in Firefox and Chrome. Dashjs player does not work and I have tried "everything". Does someone see a bug in my test page, I have tried org.w3.clearkey serverURL and clearkeys[] syntax to pass KID=KEY pair.
ShakaPlayer https://m.dtv.fi/dash/index_clearkey.html?video=1 Dashjs https://m.dtv.fi/dash/index_clearkey2.html?video=1 Mpd(drm,pssh v0) https://m.dtv.fi/dash/dasherh264/drm/manifest_clearkey.mpd Mpd(drm,pssh v1) https://m.dtv.fi/dash/dasherh264/drm2/manifest.mpd Mpd(free) https://m.dtv.fi/dash/dasherh264/manifest.mpd
EDIT: I think have found a reason and it's PSSHv0/PSSHv1 table in an init section to mess things up in dashjs player. ShakaPlayer tolerates v0 in Chrome and Firefox, also ShakaPlayer tolerates v1 in Chrome.
EDIT: pullrequest-#2318 This version works in Firefox,Chrome,Operabeta https://m.dtv.fi/dash/index_clearkey2-pr2318.html?video=14
ShakaPlayer, PSSHv0 in init, PSSHv1 in manifest: Chrome=ok, Firefox=ok https://m.dtv.fi/dash/index_clearkey.html?video=1
DashjsPlayer, PSSHv0 in init, PSSHv1 in manifest: Chrome=fail, Firefox=fail https://m.dtv.fi/dash/index_clearkey2.html?video=1
ShakaPlayer, PSSHv1 in init, PSSHv1 in manifest: Chrome=ok, Firefox=fail https://m.dtv.fi/dash/index_clearkey.html?video=12
DashjsPlayer, PSSHv1 in init, PSSHv1 in manifest: Chrome=ok, Firefox=fail https://m.dtv.fi/dash/index_clearkey2.html?video=12
Shakaplayer and DashjsPlayer play non-protected video: Chrome=ok, Firefox=ok https://m.dtv.fi/dash/index_clearkey.html?video=2 https://m.dtv.fi/dash/index_clearkey2.html?video=2
Console logs from Chrome dashjs test page using LAURL address.
Navigated to https://m.dtv.fi/dash/index_clearkey2.html
Debug.js:112 [16] [dash.js 2.6.2] MediaPlayer has been initialized
Debug.js:112 [24] EME detected on this user agent! (ProtectionModel_21Jan2015)
Debug.js:112 [43] Playback Initialized
Debug.js:112 [141] Parsing complete: ( xml2json: 17.5ms, objectiron: 8.69ms, total: 0.0262s)
Debug.js:112 [161] SegmentTimeline detected using calculated Live Edge Time
Debug.js:112 [175] MediaSource attached to element. Waiting on open...
Debug.js:112 [176] Manifest has been refreshed at Tue Oct 24 2017 12:53:07 GMT+0300 (FLE Daylight Time)[1508838787.597]
Debug.js:112 [178] MediaSource is open!
Debug.js:112 [179] Duration successfully set to: 90.005
Debug.js:112 [181] Added 0 inline events
Debug.js:112 [185] video codec: video/mp4;codecs="avc1.4d4028"
Debug.js:112 [232] audio codec: audio/mp4;codecs="mp4a.40.2"
Debug.js:112 [237] No text data.
Debug.js:112 [237] No fragmentedText data.
Debug.js:112 [238] No embeddedText data.
Debug.js:112 [239] No muxed data.
Debug.js:112 [250] Schedule controller starting for video
Debug.js:112 [251] Schedule controller starting for audio
Debug.js:112 [251] Start Event Controller
Debug.js:112 [253] DRM: KeySystem Access Granted (org.w3.clearkey)! Selecting key system...
Debug.js:112 [254] Native video element event: play
Debug.js:112 [258] ScheduleController - getNextFragment
Debug.js:112 [258] ScheduleController - switch track has been asked, get init request for video with representationid = v1
Debug.js:112 [263] ScheduleController - getNextFragment
Debug.js:112 [264] ScheduleController - switch track has been asked, get init request for audio with representationid = a1
Debug.js:112 [269] DRM: Session created. SessionID = 0B986F0423000000
Debug.js:112 [271] DRM: onKeyMessage
Debug.js:112 [273] Failed to retrieve clearkeys from ProtectionData
Debug.js:112 [312] Init fragment finished loading saving to video's init cache
Debug.js:112 [318] DRM: onNeedKey
Debug.js:112 [319] DRM: initData: &pssh ðy@B«æ[à_ ü< W R M H E A D E R x m l n s = " h t t p : / / s c h e m a s . m i c r o s o f t . c o m / D R M / 2 0 0 7 / 0 3 / P l a y R e a d y H e a d e r " v e r s i o n = " 4 . 0 . 0 . 0 " > < D A T A > < P R O T E C T I N F O > < K E Y L E N > 1 6 < / K E Y L E N > < A L G I D > A E S C T R < / A L G I D > < / P R O T E C T I N F O > < K I D > e F Y h Q z Q S N B I S N B I 0 E j Q S N A = = < / K I D > < C H E C K S U M > m u h j T 9 u C a s s = < / C H E C K S U M > < / D A T A > < / W R M H E A D E R > 4pssh íï©yÖJΣÈ'ÜÕ!í C!Vx444444 8pssh iù¯HFêÍ]ÌË
: marl mkid 4pssh wïìÀ²M¬ã<RâûK C!Vx444444
Debug.js:112 [321] DRM: KeySystem Access Granted
Debug.js:112 [323] Error generating key request -- NotSupportedError
Debug.js:112 [326] Schedule controller stopping for video
Debug.js:112 [328] Schedule controller stopping for audio
Debug.js:112 [329] Native video element event: pause
Console logs from Chrome dashjs test page using embedded clearkey property.
Navigated to https://m.dtv.fi/dash/index_clearkey2.html
Debug.js:112 [17] [dash.js 2.6.2] MediaPlayer has been initialized
Debug.js:112 [25] EME detected on this user agent! (ProtectionModel_21Jan2015)
Debug.js:112 [42] Playback Initialized
Debug.js:112 [152] Parsing complete: ( xml2json: 21.6ms, objectiron: 9.16ms, total: 0.0307s)
Debug.js:112 [164] SegmentTimeline detected using calculated Live Edge Time
Debug.js:112 [174] MediaSource attached to element. Waiting on open...
Debug.js:112 [176] Manifest has been refreshed at Tue Oct 24 2017 12:55:19 GMT+0300 (FLE Daylight Time)[1508838919.1]
Debug.js:112 [178] MediaSource is open!
Debug.js:112 [179] Duration successfully set to: 90.005
Debug.js:112 [182] Added 0 inline events
Debug.js:112 [185] video codec: video/mp4;codecs="avc1.4d4028"
Debug.js:112 [220] audio codec: audio/mp4;codecs="mp4a.40.2"
Debug.js:112 [224] No text data.
Debug.js:112 [224] No fragmentedText data.
Debug.js:112 [225] No embeddedText data.
Debug.js:112 [225] No muxed data.
Debug.js:112 [232] Schedule controller starting for video
Debug.js:112 [233] Schedule controller starting for audio
Debug.js:112 [234] Start Event Controller
Debug.js:112 [236] DRM: KeySystem Access Granted (org.w3.clearkey)! Selecting key system...
Debug.js:112 [237] Native video element event: play
Debug.js:112 [246] ScheduleController - getNextFragment
Debug.js:112 [246] ScheduleController - switch track has been asked, get init request for video with representationid = v1
Debug.js:112 [253] ScheduleController - getNextFragment
Debug.js:112 [254] ScheduleController - switch track has been asked, get init request for audio with representationid = a1
Debug.js:112 [259] DRM: Session created. SessionID = EB4C3F7527000000
Debug.js:112 [261] DRM: onKeyMessage
Debug.js:112 [263] DRM: ClearKey license request handled by application!
Debug.js:112 [299] Init fragment finished loading saving to video's init cache
Debug.js:112 [305] DRM: onNeedKey
Debug.js:112 [306] DRM: initData: &pssh ðy@B«æ[à_ ü< W R M H E A D E R x m l n s = " h t t p : / / s c h e m a s . m i c r o s o f t . c o m / D R M / 2 0 0 7 / 0 3 / P l a y R e a d y H e a d e r " v e r s i o n = " 4 . 0 . 0 . 0 " > < D A T A > < P R O T E C T I N F O > < K E Y L E N > 1 6 < / K E Y L E N > < A L G I D > A E S C T R < / A L G I D > < / P R O T E C T I N F O > < K I D > e F Y h Q z Q S N B I S N B I 0 E j Q S N A = = < / K I D > < C H E C K S U M > m u h j T 9 u C a s s = < / C H E C K S U M > < / D A T A > < / W R M H E A D E R > 4pssh íï©yÖJΣÈ'ÜÕ!í C!Vx444444 8pssh iù¯HFêÍ]ÌË
: marl mkid 4pssh wïìÀ²M¬ã<RâûK C!Vx444444
Debug.js:112 [307] DRM: KeySystem Access Granted
Debug.js:112 [309] Error generating key request -- NotSupportedError
Debug.js:112 [311] Schedule controller stopping for video
Debug.js:112 [312] Schedule controller stopping for audio
Debug.js:112 [314] Native video element event: pause
Manifest
<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd" xmlns:mspr="urn:microsoft:playready" maxSegmentDuration="PT0H0M6.000S" mediaPresentationDuration="PT0H1M30.005S" minBufferTime="PT3.000S" profiles="urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash264,urn:hbbtv:dash:profile:isoff-live:2012" type="static">
<Period duration="PT0H1M30.005S" id="p0">
<AdaptationSet lang="und" maxFrameRate="25" maxHeight="1080" maxWidth="1920" par="16:9" segmentAlignment="true" startWithSAP="1">
<SegmentTemplate initialization="$RepresentationID$_i.mp4" media="$RepresentationID$_$Number$.m4s" startNumber="1" timescale="1000">
<SegmentTimeline>
<S d="6000" r="14" t="0"/>
</SegmentTimeline>
</SegmentTemplate>
<ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341234" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAFDIVZ4EjQSNBI0EjQSNBI0AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation bandwidth="491871" codecs="avc1.4d4028" frameRate="25" height="360" id="v1" mimeType="video/mp4" sar="1:1" width="640">
</Representation>
<Representation bandwidth="1411922" codecs="avc1.4d4028" frameRate="25" height="720" id="v2" mimeType="video/mp4" sar="1:1" width="1280">
</Representation>
<Representation bandwidth="1955820" codecs="avc1.4d4028" frameRate="25" height="1080" id="v3" mimeType="video/mp4" sar="1:1" width="1920">
</Representation>
</AdaptationSet>
<AdaptationSet lang="und" segmentAlignment="true" startWithSAP="1">
<SegmentTemplate initialization="$RepresentationID$_i.mp4" media="$RepresentationID$_$Number$.m4s" startNumber="1" timescale="1000">
<SegmentTimeline>
<S d="5973" t="0"/>
<S d="5995" r="1"/>
<S d="5994"/>
<S d="5995" r="1"/>
<S d="5994"/>
<S d="5995"/>
<S d="5994"/>
<S d="5995" r="2"/>
<S d="5994"/>
<S d="5995" r="1"/>
<S d="106"/>
</SegmentTimeline>
</SegmentTemplate>
<ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341234" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAFDIVZ4EjQSNBI0EjQSNBI0AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation audioSamplingRate="48000" bandwidth="136244" codecs="mp4a.40.2" id="a1" mimeType="audio/mp4">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
ClearKey license url script is using a different url syntax in Shaka and Dashjs, this script handles both formats and returns a json kid-key pair.
https://m.dtv.fi/dash/laurl_ck.php
SkahaPlayer POST
POST: {"kids":["QyFWeBI0EjQSNBI0EjQSNA"],"type":"temporary"}
REPLY: {"keys": [{"k": "EjQSNBI0EjQSNBI0EjQSNA", "kty": "oct", "kid": "QyFWeBI0EjQSNBI0EjQSNA" }], "type": "temporary"}
Dashjs GET
GET: https://m.dtv.fi/dash/laurl_ck.php?/?QyFWeBI0EjQSNBI0EjQSNA
REPLY: {"keys": [{"k": "EjQSNBI0EjQSNBI0EjQSNA", "kty": "oct", "kid": "QyFWeBI0EjQSNBI0EjQSNA" }], "type": "temporary"}
Dashjs script in index_clearkey2.html page
function initApp() {
var player = dashjs.MediaPlayer().create();
player.initialize();
player.setAutoPlay(true);
player.setProtectionData({
"org.w3.clearkey": { "serverURL" : laUrl }
//"org.w3.clearkey": { "clearkeys": { "QyFWeBI0EjQSNBI0EjQSNA":"EjQSNBI0EjQSNBI0EjQSNA" } } // KID=KEY
});
player.attachView( document.querySelector("#video") );
player.attachSource(manifestUrl);
}
document.addEventListener('DOMContentLoaded', initApp);