videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
203 stars 72 forks source link

HLS is not working with clearkey: ERROR: (CODE:3 MEDIA_ERR_DECODE) Playback cannot continue. No available working or supported playlists. #158

Closed cdgriffith closed 2 years ago

cdgriffith commented 2 years ago

HLS is not working with clearkey for me. Tested on Chrome and Firefox on Windows 11. I have detailed example / files attached here: enc_example.zip

Simply run python3 https_server.py and navigate to "https://127.0.0.1:8444"

videojs

The actual key and IV are referenced directly in the simple m3u8 file that works correctly with mpv accessing it. #EXT-X-KEY:METHOD=AES-128,URI="https://127.0.0.1:8444/key/a1aee6b36cef66cdcce2191fb15ababd.key",IV=0x763a312f2edf357c

Can test to make sure the encrypted version is working with mpv if you have it: mpv https://127.0.0.1:8444/point.m3u8 --demuxer-lavf-o=protocol_whitelist=[file,tcp,tls,http,https,crypto,data]

Using the most basic of player setups possible:

<!DOCTYPE html>
<html lang="en">
<head>
    <link href="https://vjs.zencdn.net/7.17.0/video-js.css" rel="stylesheet"/>
    <title>Streamer</title>
</head>
<body>
<div style="float:left"> 
<h2>Encrypted</h2>
<video id=vid1 class="video-js" controls></video>
</div>

<div style="float: right"> 
<h2>Regular</h2>
<video id=vid2 class="video-js" controls></video>
</div>
<script src="https://vjs.zencdn.net/7.17.0/video.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/videojs-contrib-eme@4.0.0/dist/videojs-contrib-eme.js"
        integrity="sha256-Re3uRfAQT8Ngbr8q+/qGgBKZcMUti7qWs4vCMXYunMA=" crossorigin="anonymous"></script>
<script>
    window.onload = function () {
        let player = videojs('vid1');

        player.eme();
        player.src({
            src: '/point.m3u8',
            type: 'application/x-mpegURL'
        });

        let player2 = videojs('vid2');
        player2.src({
            src: '/point_regular.m3u8',
            type: 'application/x-mpegURL'
        });

    };
</script>
</body>
</html>

Any help would be appreciated!

cdgriffith commented 2 years ago

Well in this case after a deeper dive it seems that a wrong IV was used during the encryption of the video segments. Somehow mpv still plays it even with a bad IV but video.js does not (probably the correct behavior actually). Not sure how mpv is ignoring the IV for AES-128 CBC