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

Trying to run DRM protected stream with AES 128 using hls.js #3052

Closed
varshney123 opened this issue Sep 23, 2020 · 4 comments
Closed

Trying to run DRM protected stream with AES 128 using hls.js #3052

varshney123 opened this issue Sep 23, 2020 · 4 comments

Comments

@varshney123
Copy link

varshney123 commented Sep 23, 2020

Hi, I was integrating hls.js to run DRM protected stream in my player.

When tried with an open stream (not DRM protected)
Stream URL - [https://d6k7l6hrzgp1m.cloudfront.net/convert/streams/HLS/SD/index.m3u8]

Player Successfully played the stream without any issues.

But when used the same stream of same packaging and format but with DRM protection it shows the error
"Buffer add codec error for audio/mpeg;codecs=mp4a.40.2:Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('audio/mpeg;codecs=mp4a.40.2') is unsupported"

I have used the below mentioned configuration to configure hls.js to run DRM protected stream
var config = { "debug": true, emeEnabled: true, requestMediaKeySystemAccessFunc : requestMediaKeySystemAccess, widevineLicenseUrl: "https://hsc.test.ott.irdeto.com/licenseServer/widevine/v1/hsc/license?contentId=DASH_SAMPLE_CONTENT", licenseXhrSetup: function(xhr, url) { xhr.setRequestHeader('Content-Type', 'application/octet-stream'); xhr.setRequestHeader('Authorization', "") } } var hls = new Hls(config);
Please find the below mentioned logs

[log] > attachMedia
hls.js@latest:formatted:106 [log] > media source closed
hls.js@latest:formatted:106 [log] > media source opened
player.html:202 video and hls.js are now bound together !
hls.js@latest:formatted:106 [log] > loadSource:https://d6k7l6hrzgp1m.cloudfront.net/convert/streams/HLS/wv/aes128/index.m3u8
hls.js@latest:formatted:106 [log] > trigger BUFFER_RESET
hls.js@latest:formatted:106 [log] > manifest loaded,1 level(s) found, first bitrate:258310
hls.js@latest:formatted:106 [log] > 1 bufferCodec event(s) expected
hls.js@latest:formatted:106 [log] > startLoad(-1)
hls.js@latest:formatted:106 [log] > switching to level 0
hls.js@latest:formatted:106 [log] > main stream-controller: STOPPED->IDLE
hls.js@latest:formatted:106 [log] > audio tracks updated
hls.js@latest:formatted:106 [log] > Requesting encrypted media key-system access
player.html:182 It is recommended that a robustness level be specified. Not specifying the robustness level could result in unexpected behavior.
player.html:205 manifest loaded, found 1 quality level
hls.js@latest:formatted:106 [log] > subtitle tracks updated
hls.js@latest:formatted:106 [log] > Access for key-system "com.widevine.alpha" obtained
hls.js@latest:formatted:106 [log] > level 0 loaded [1,14],duration:151
hls.js@latest:formatted:106 [log] > Loading key for 1 of [1-14], level 0
hls.js@latest:formatted:106 [log] > main stream-controller: IDLE->KEY_LOADING
hls.js@latest:formatted:106 [log] > main stream-controller: KEY_LOADING->IDLE
hls.js@latest:formatted:106 [log] > Loading 1 of [1-14], level 0, nextLoadPosition: 0, bufferEnd: 0
hls.js@latest:formatted:106 [log] > demuxing in webworker
hls.js@latest:formatted:106 [log] > main stream-controller: IDLE->FRAG_LOADING
hls.js@latest:formatted:106 [log] > Loaded 1 of [1 ,14],level 0
hls.js@latest:formatted:106 [log] > Parsing 1 of [1 ,14],level 0, cc 0
hls.js@latest:formatted:106 [log] > main stream-controller: FRAG_LOADING->PARSING
hls.js@latest:formatted:106 [log] > main:discontinuity detected
hls.js@latest:formatted:106 [log] > main:switch detected
hls.js@latest:formatted:106 [log] > Media-keys created for key-system "com.widevine.alpha"
hls.js@latest:formatted:106 [log] > New key-system session
f9a0b0de-7a1a-4c0f-a787-6ece6157d6e4:1 [log] > WebCrypto AES decrypt
f9a0b0de-7a1a-4c0f-a787-6ece6157d6e4:1 [log] > WebCrypto Error, disable WebCrypto API
f9a0b0de-7a1a-4c0f-a787-6ece6157d6e4:1 [log] > JS AES decrypt
f9a0b0de-7a1a-4c0f-a787-6ece6157d6e4:1 [log] > audio sampling rate : 12000
hls.js@latest:formatted:106 [log] > InitPTS for cc: 0 found from main: 0
hls.js@latest:formatted:106 [log] > creating sourceBuffer(audio/mpeg;codecs=mp4a.40.2)
hls.js@latest:formatted:106 [error] > error while trying to add sourceBuffer:Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('audio/mpeg;codecs=mp4a.40.2') is unsupported.
(anonymous) @ hls.js@latest:formatted:106
a.createSourceBuffers @ hls.js@latest:formatted:7519
a.checkPendingTracks @ hls.js@latest:formatted:7463
a.onBufferCodecs @ hls.js@latest:formatted:7491
t.onEventGeneric @ hls.js@latest:formatted:3596
t.onEvent @ hls.js@latest:formatted:3585
d.emit @ hls.js@latest:formatted:877
i.trigger @ hls.js@latest:formatted:5092
h.onFragParsingInitSegment @ hls.js@latest:formatted:6232
t.onEventGeneric @ hls.js@latest:formatted:3596
t.onEvent @ hls.js@latest:formatted:3585
d.emit @ hls.js@latest:formatted:877
i.trigger @ hls.js@latest:formatted:5092
t.onWorkerMessage @ hls.js@latest:formatted:5230
hls.js@latest:formatted:106 [log] > main track:audio,container:audio/mpeg,codecs[level/parsed]=[mp4a.40.2/]
hls.js@latest:formatted:106 [log] > Parsed audio,PTS:[0.000,0.120],DTS:[0.000/0.120],nb:4,dropped:0
hls.js@latest:formatted:106 [log] > main stream-controller: PARSING->PARSED

Update

I have tested the provided unprotected stream https://d6k7l6hrzgp1m.cloudfront.net/convert/streams/HLS/SD/index.m3u8 on Safari Browser MacOs Catalina. It is streaming perfectly creating sourcebuffer with format (audio/mp4;codecs=mp4a.40.2).

But when same format of stream used as widevine DRM protected , its creating sourcebuffer with format (audio/mpeg;codecs=mp4a.40.2)

Also followed this https://github.com/video-dev/hls.js/pull/1190 for the reference but it does not proves that it worked for DRM protected streams.

Need Urgent help. Thanks in advance

@tchakabam
Copy link
Collaborator

Hi @varshney123

The information you provide so far isn't conclusive.

There is a difference between DRM and just encrypting a stream (AES-128 being the standard supported way to do that).

If you say you do DRM, which type of DRM are you using (Widevine, FairPlay, ... ?)

@varshney123
Copy link
Author

varshney123 commented Oct 13, 2020 via email

@tchakabam
Copy link
Collaborator

tchakabam commented Oct 14, 2020

Hi Aakash,

Yes no doubt DRM implies encryption. But you can have encryption without DRM :) That was what I wanted to gain clarity about.

Answers for you:

With any of the two last points, please feel free to contact me directly for any further help or questions.

Best,
Stephan (stephan@emliri.com)

@robwalch
Copy link
Collaborator

robwalch commented Oct 20, 2022

HLS.js will support ISO-23001-7, SAMPLE-AES ,SAMPLE-AES-CENC ,SAMPLE-AES-CTR key methods with EME. The AES-128 method is not supported with EME. See #4930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants