Open bigt11 opened 7 years ago
Hi,
I got quite the same questions. @bigt11 did you manage to answer some of them?
While I'm not too familiar with the dash.js specific content protection settings, it might be possible to make use of https://github.com/videojs/videojs-contrib-eme as a mechanism for using clearkey. There are a couple examples using clearkey in index-player-options.html and index-source-options.html.
And if it doesn't make sense to use the separate system, and you end up using dash.js' protection scheme, the examples might at least help with the base64 portion.
@bigt11 Were you able to set clearkey options in the player ?
@mhassanist I have not gotten dash to work with clearkey, because I have not tried since failing because of my first post. I did attempt to use videojs-contrib-eme but had issues with that, but I abandoned that also. For my needs i am no longer using fragmented media, just a regular video - webm that has been encrypted via webmtools and I used the source code from here to make it work. https://simpl.info/eme/clearkey/
@bigt11 I was able to get the clear key to work in shaka player if you are interested in this. Refer to https://github.com/videojs/videojs-contrib-eme/issues/20
But I need to use VideoJs which I still could not setup the clear key options there. As for your solution, Would you please advice how were you able to encrypt the media using webmtool ? Because I get error while encrypting. Please check here: https://stackoverflow.com/questions/44946042/error-encrypting-webm-video-with-webm-crypt/44971808#44971808
@mhassanist
webm_crypt is only for webm files and not mp4 I believe.
here are some notes i wrote down to compile and use webm_crypt, you will have to see if you can struggle through the notes to compile the webm_crypt. I compiled on a pi3 with ubuntu on it. I have not used these notes in a while, but this is what i have to create and use the webm_crypt program. I am also encrypting the video and audio using the same key. I realy was only able to play it back using https://simpl.info/eme/clearkey/ . I had problems with contrib-eme for videojs, I never got it to work with contrib-eme. I used there examples and test files, and it worked, but as soon as I swaped the file out and key out, then it did not work. I am only ever using webm, no mp4 because of royalty's. Also I am not segmenting the files, just using a single file that is encrypted. Please let me know if you get contrib-eme to work using a webm_crypt file. Also remember, for me and the simpl.info example, you need to change alg: 'A128CTR',
. It seems like webm_crypt uses the ctr algorithm, no way to change that in options of webm_crypt that I have seen.
`BUILD WEBMTOOLS https://github.com/webmproject/webm-tools/tree/master/webm_crypt
http://wiki.webmproject.org/zz-obsolete/instructions-to-playback-a-webm-dash-presentation This link has some instructions on the encrypting process in the section titled 2.27 optional encrypting the video streams
$ cd ~/src/webm The below 2 gits will be in the folder webm //will complain about missing openssl/aes.h so install libssl-dev $ sudo apt-get install libssl-dev $ git clone https://github.com/webmproject/libwebm.git $ git clone https://github.com/webmproject/webm-tools.git $ cd libwebm $make -f Makefile.unix $ cd .. To get into the webm folder $ cd webm-tools/webm_crypt $ make $ ./webm_crypt -test Look for tests passed at bottom
Encrypt and generate a key
Assuming you are in the web_crypt folder
If you do an initial encrypt, it will generate a key for you. The First step is to encrypt one of WebM video files. This will also generate a key file. $ ./webm_crypt -i myfilename.webm -o encrypted_myfilename.webm This will generate vid_base_secret.key
If you want to encrypt the audio also and get a key, you can do $ ./webm_crypt -i myfilename.webm -o encrypted_myfilename.webm -audio true -video true This will generate vid_base_secret.key and aud_base_secret.key
Encrypt using a key $ ./webm_crypt -i myfilename.webm -o encrypted_myfilename.webm -audio true -video true -audio_options base_file=pathtoaudiokey.key -video_options base_file=pathtovideokey.key
Decrypt using a key $ ./webm_crypt -i encrypted_myfilename.webm -o decrypted_myfilename.webm -audio true -video true -decrypt -audio_options base_file=pathtoaudiokey.key -video_options base_file=pathtovideokey.key `
Thanks a lot @bigt11 for your advice on this. It was really useful.
@bigt11 @gesinger i also want to use clearkey but i get no solution in it. there are very few documentation so please give me a piece of advice. I encrypted the video using bento4 tool and i have keys and all the things.. i already see #194 and many other things. i also try to run videojs-contrib-eme example but they are also showing errors like plugin "eme" not exist. i don't want to use Shaka Player.
@avinash-chopra I was not able to get the contrib-dash plugin working yet for my project, but for playing back encrypted media offline. Right now, I am only doing a single video and not fragmenting it up. I encrypted the video like in this post like I previously mentioned and used this links "Clear Key" instructions to decrypt it https://www.html5rocks.com/en/tutorials/eme/basics/
I have not been able to jump back on this issue yet to see if i can get it to work with fragmented files at all. But if playback is offline, I don't see a need to use dash, maybe just stick with a single file.
I want to use clear key for decryption and not any drm. My intent is to pass the decryption key via passing options to dash.js. I am assuming I should use "setProtectionData" option in the videojs setup like the dash docs say to do, or If i need to also do something with keySystemOptions?
In short, I want to just provide my own key locally to decrypt the dash content.
info on protectiondata is located here http://vm2.dashif.org/dash.js/docs/jsdocs/MediaPlayer.vo.protection.ProtectionData.html
I am using bento4 to make the encryption content https://www.bento4.com/developers/dash/encryption-and-drm/
bento4 encode command.
mp4dash --encryption-key=121a0fca0f1b475b8910297fa8e0a07e:a0a1a2a3a4a5a6a7a8a9aaabacadaeaf source_400kbps.mp4
Here is my js code. I am confused on this because ProtectionData uses 3 parameters, but I have no no serverURL, or headers, just the 3rd parameter "clearkeys" that is relevant to me.
Also I am a bit confused on the key. ProtectionData asks for base64-encoded (no padding) so if my key that was inputed into bento4 is "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" would the base 64 no padding key be "YTBhMWEyYTNhNGE1YTZhN2E4YTlhYWFiYWNhZGFlYWY="