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


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

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>
        <title>Dash.js Rocks</title>
            video {
                width: 640px;
                height: 360px;
            <video id="videoPlayer" controls></video>
        <script src=""></script>
                const protData = {
                    "org.w3.clearkey": {
                        "clearkeys": {
                            "oW5AK5BW43HzbTSKpiu3SQ": "hyN9IKGfWKdAwFaE5pm0qg"

                var url = "/out/b.mpd";
                var player = dashjs.MediaPlayer().create();
                video = document.querySelector("#videoPlayer");
                player.initialize(video, url);

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

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


Change History (2)

comment:1 by Chris Miceli, 4 years ago

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.

comment:2 by Carl Eugen Hoyos, 4 years ago

Component: ffmpegavformat
Keywords: cenc removed
Priority: normalwish
Note: See TracTickets for help on using tickets.