[FFmpeg-trac] #8808(ffmpeg:new): Adding CENC ClearKey encryption support to DASH

FFmpeg trac at avcodec.org
Mon Jul 20 18:39:08 EEST 2020

#8808: Adding CENC ClearKey encryption support to DASH
             Reporter:  qfsw       |                     Type:  enhancement
               Status:  new        |                 Priority:  normal
            Component:  ffmpeg     |                  Version:  git-master
             Keywords:  dash cenc  |               Blocked By:
             Blocking:             |  Reproduced by developer:  0
Analyzed by developer:  0          |
 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

 av_dict_set(&opts, "encryption_scheme", "cenc-aes-ctr", 0);
 av_dict_set(&opts, "encryption_key", "87237D20A19F58A740C05684E699B4AA",
 av_dict_set(&opts, "encryption_kid", "A16E402B9056E371F36D348AA62BB749",

 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>
                 const protData = {
                     "org.w3.clearkey": {
                         "clearkeys": {

                 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

 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


Ticket URL: <https://trac.ffmpeg.org/ticket/8808>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list