[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
 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!

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


More information about the FFmpeg-trac mailing list