Opened 4 years ago
Last modified 4 years ago
#8808 new enhancement
Adding CENC ClearKey encryption support to DASH
Reported by: | qfsw | Owned by: | |
---|---|---|---|
Priority: | wish | Component: | avformat |
Version: | git-master | Keywords: | dash |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I've been working on modifying FFmpeg to have support for ClearKey CENC encryption when producing MPEG-DASH content but cant quite seem to get it to work
As a test, I've hardcoded the dash encoder to always pass encryption options over to the MP4 muxer, I added the following lines to line 1648 of dashenc.c
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/dashenc.c#L1648
av_dict_set(&opts, "encryption_scheme", "cenc-aes-ctr", 0); av_dict_set(&opts, "encryption_key", "87237D20A19F58A740C05684E699B4AA", 0); av_dict_set(&opts, "encryption_kid", "A16E402B9056E371F36D348AA62BB749", 0);
I have then built ffmpeg and used it to convert an MP4 file to DASH content, which I then play with the following dash.js player
<!doctype html> <html> <head> <title>Dash.js Rocks</title> <style> video { width: 640px; height: 360px; } </style> </head> <body> <div> <video id="videoPlayer" controls></video> </div> <script src="http://cdn.dashjs.org/latest/dash.all.debug.js"></script> <script> (function(){ const protData = { "org.w3.clearkey": { "clearkeys": { "oW5AK5BW43HzbTSKpiu3SQ": "hyN9IKGfWKdAwFaE5pm0qg" } } }; var url = "/out/b.mpd"; var player = dashjs.MediaPlayer().create(); video = document.querySelector("#videoPlayer"); player.setProtectionData(protData); player.setAutoPlay(false); player.initialize(video, url); })(); </script> </body> </html>
This fails to play. The same player does work with both the non modified version of ffmpeg (and hence non encrypted), as well as the output of Bento4
https://github.com/Dash-Industry-Forum/dash.js/wiki/Generate-MPEG-DASH-content-encrypted-with-MPEG-CENC-ClearKey
With the modified FFmpeg, Opera yields these errors in the console
[169][StreamController] Video Element Error: MEDIA_ERR_DECODE (CHUNK_DEMUXER_ERROR_APPEND_FAILED: Append: stream parsing failed. Data size=3491 append_window_start=0 append_window_end=33.3)
Does anyone have any pointers of anything else that must be done to make this work, or what else I can do to investigate the issue? I thought that perhaps the MPD required modification, but the output from Bento4 has no mentions to the CENC encryption at all and plays correctly
Thanks!
Change History (2)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Component: | ffmpeg → avformat |
---|---|
Keywords: | cenc removed |
Priority: | normal → wish |
Can you potentially upload the assets which you used for testing?
The dash specification specifies a "ContentProtection" tag but I'm not sure if it MUST be present vs CAN be present.