shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.14k stars 1.34k forks source link

6001 error while trying to play CENC AES-CTR encrypted mp4 file #5671

Closed mouhandalkadri closed 1 year ago

mouhandalkadri commented 1 year ago

I am experimenting with clear key encryption. Basically what I am doing is encrypting an mp4 file using CENC AES-CTR and play it using Shaka Player but I am facing 6001 error.

I tried using ffmpeg to encrypt the file as follows:

ffmpeg -i .\video.mp4 -vcodec copy -acodec copy -encryption_scheme cenc-aes-ctr -encryption_key 76a6c65c5ea762046bd749a2e632ccbb -encryption_kid a7e61c373e219033c21091fa607bf3b8 out.mp4

Also tried to use mp4box

mp4box -crypt .\drm_file.xml .\video.mp4 -out out.mp4

and here's my drm_file.xml

<?xml version="1.0" encoding="UTF-8" ?>
<GPACDRM type="CENC AES-CTR">
<!-- 
  kid=0x43215678123412341234123412341234
  key=0x12341234123412341234123412341234
  iv=0x22ee7d4745d3a26a
--> 

<!-- CENC -->
<DRMInfo type="pssh" version="1">
  <BS ID128="1077efecc0b24d02ace33c1e52e2fb4b"/>
  <BS bits="32" value="1"/>
  <BS ID128="43215678123412341234123412341234"/>
</DRMInfo>

<CrypTrack trackID="1" IsEncrypted="1" IV_size="8" first_IV="0x22ee7d4745d3a26a" saiSavedBox="senc">
  <key KID="0x43215678123412341234123412341234" value="0x12341234123412341234123412341234"/>
</CrypTrack>

</GPACDRM>

and I am running the shaka player as follows:

  async function main() {
      shaka.polyfill.installAll();
      if (shaka.Player.isBrowserSupported()) {
          try {
              const video = document.getElementsByTagName("video")[0];
              const player = new shaka.Player(video);
              player.configure({
                  drm: {
                      clearKeys: {
                          [id]: key,
                      }
                  }
              })

              player.addEventListener('error', console.error);

              await player.load(url);

          } catch (er) {
              console.error(er)
          }

      } else {
          // This browser does not have the minimum set of APIs we need.
          console.error('Browser not supported!');
      }
  }

and I did tried all the above on different files, but got the same error image

I am sure I am missing something, anyone has any idea what could the issue?

joeyparrish commented 1 year ago

Does your browser support ClearKey? Some don't. I think Safari, in particular, does not implement it.

Check the drm section of https://shaka-player-demo.appspot.com/support.html for a quick diagnostic.

mouhandalkadri commented 1 year ago

I am using the latest version of Edge and I tested on the latest version of Google Chrome,, but still in the drm section of the link you provided I am getting this

  "org.w3.clearkey": {
    "persistentState": false
  },

does that mean ClearKey isn't supported ? and if so, in which browsers it is ?

avelad commented 1 year ago

@mouhandalkadri Can you provide the manifest URL to see what is happening? Thanks!

shaka-bot commented 1 year ago

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.