videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
203 stars 72 forks source link

Can't make the simple ClearKey encryption example work #101

Open Th0masL opened 4 years ago

Th0masL commented 4 years ago

Hi,

I'm new to videojs, HLS/DASH streaming and encryption/DRM, so I'm going through the examples and try to work my way up to understand exactly how to use this tool.

My needs are simple, as I don't need any official DRM protection. I only want to encrypt the video files with ClearKey, and I don't need to hide the encryption key (the key can be visible in the source code, I don't mind for the moment).

So I've been trying to use the simple example of the encrypted "moose_encrypted.webm" provided in the file videojs-contrib-eme/index-player-options.html but it doesn't work on my side.

The error I get is the following :

Media resource http://mywebsite.local/moose_encrypted.webm could not be decoded.

VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported. 
    code: 4
​    message: "The media could not be loaded, either because the server or network failed or because the format is not supported."
​
<prototype>: Object { code: 0, MEDIA_ERR_CUSTOM: 0, MEDIA_ERR_ABORTED: 1, … }
video.js:80:49
    LogByTypeFactory https://unpkg.com/video.js/dist/video.js:80
    error https://unpkg.com/video.js/dist/video.js:268
    error https://unpkg.com/video.js/dist/video.js:27666
    handleTechError_ https://unpkg.com/video.js/dist/video.js:25959
    dispatcher https://unpkg.com/video.js/dist/video.js:1866

The only thing that I have changed from the files I cloned from this Git repository is the path to the .css and .js files, to use the latest version of videojs/EME :

<link href="https://unpkg.com/video.js/dist/video-js.css" rel="stylesheet">
<script src="https://unpkg.com/video.js/dist/video.js"></script>
<script src="https://cdn.jsdelivr.net/npm/videojs-contrib-eme@3.6.0/dist/videojs-contrib-eme.js"></script>

This example has been last updated in 2017, so maybe there are things that are not up to date anymore ?

Could someone offer another simple working example of a basic ClearKey implementation that is working with the current version of videojs/EME ?

gkatsev commented 4 years ago

It really depends on what your backend does when it returns the license and certificate. You may just be able to provide certificateUri or licenseUri rather than using the example. The example shows how you could need processing of the license response to modify it into a value that's useable. I would recommend reading the README and trying again. If you can produce a test case, we can help with figuring out the configuration exactly.

sbbullet commented 4 years ago

I also am facing this issue. Please help us with the solution.

player.src({ keySystems: { 'org.w3.clearkey' : { getLicense: function(emeOptions, keyMessage, callback){ let keysObject = { "keys": [ { "kty": "oct", "kid": "xnpHFy0Xwd65XCmlKRLTyA", "k": "-j_gr_b9eZfN6Dk28HIyXA" }, { "kty": "oct", "kid": "XH2uNF-6acnCVa4aiYN-4w", "k": "D9sjE4x_5glfXvAE7RAsrg" }, { "kty": "oct", "kid": "plOH2VBd59S9MvSnBz6ndg", "k": "aZsxA1itdQZScbuNgNTYKA" } ] }; callback(null, new TextEncoder().encode(JSON.stringify(keysObject))); } } } });

RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer

EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:text/plain;base64,plOH2VBd59S9MvSnBz6ndg==",IV=0x5F2EA3C9F06056E94FF75932E4F7C610,KEYFORMAT="identity"

Using TS container for video framents and AAC for audio fragments 3:08 The 'licenserequestattempted' event of videojs-contrib-eme is not even being emitted. 3:09 Nothing inside getLicense() function is being console logged as well.

ghost commented 9 months ago

I also would love to finally see ClearKey support with HLS.