html5-video - HTML5 播放器无法在 Chrome 上运行

标签 html5-video playready

我是 Stackoverflow 的新手,这是我的第一个问题。我的 HTML5 播放器在 Internet Explorer 上运行良好,但在 google chrome 上无法运行。我正在使用使用 CENC 加密的 PlayReady 流。我怎样才能让它在 Chrome 上工作?我无权访问服务器,它们由第三方运行。

谢谢

最佳答案

从技术上讲,当您的流媒体处于 PlayReady 状态时,可以支持 Widevine。这是可能的,因为您使用 CENC。由于您无法访问您提到的服务器,因此您可以使用一种称为 PSSH Forging 的技术。它基本上替换了让 chrome 认为它是 Widevine 的部分,因为它是 CENC,CDM 将解密视频并且流将播放。

为了简单起见,我假设您使用 DASH。

我们这里有一个 PSSH 盒子:

const widevinePSSH = '0000005c7073736800000000edef8ba979d64acea3c827dcd51d21ed0000003c080112101c773709e5ab359cbed9512bc27755fa1a087573702d63656e63221848486333436557724e5a792b32564572776e64562b673d3d2a003200';

您需要将 1c773709e5ab359cbed9512bc27755fa 替换为您的 KID。

然后在 SourceBuffer 中插入段的部分(在appendSegment之前),您可以执行以下操作:

let segment = args[0];

    segment = new Uint8Array(segment);
    const newPssh = widevinePSSH.replace('1c773709e5ab359cbed9512bc27755fa', psshKid);
    const subArray = new Uint8Array(DRMUtils.stringToArrayBuffer('70737368'));

    let index = 0;
    const found = subArray.every((item) => {
        const masterIndex = segment.indexOf(item, index);

        if (~masterIndex) {
            index = masterIndex;
            return true;
        }
    });

    if (found) {
        return originalSourceBufferAppendBuffer.apply(this, [].slice.call(args));
    }

    segment = DRMUtils.uInt8ArrayToHex(segment);

    // Inject the forged signal
    // 70737368 = pssh
    segment = segment.substr(0, segment.lastIndexOf('70737368') - 8) + newPssh + segment.substr(segment.lastIndexOf('70737368') - 8);

    // Fix the MOOV atom length
    // 6d6f6f76 = moov
    const header = segment.substr(0, segment.indexOf('6d6f6f76') - 8);
    const payload = segment.substr(segment.indexOf('6d6f6f76') - 8);
    const newLength = Math.floor(payload.length / 2);

    segment = header + DRMUtils.intToHex(newLength, 8) + payload.substr(8);

    segment = decode(segment).b;

遗憾的是,我只能分享零碎的内容,但这大致是您应该做的才能使其正常工作。

关于html5-video - HTML5 播放器无法在 Chrome 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45688270/

相关文章:

drm - 如何使用 PlayReady 加密 Smooth Streaming

http-live-streaming - 如何从 pssh 构建 PlayReady 对象

javascript - PhotoSwipe 视频

android - 视频未在 Webview 中显示

django - 为什么 .WMV 文件的 MIME 类型是 'video/x-ms-asf' 而不是 'video/x-ms-wmv'?

streaming - 我们自己设置 DRM 许可证服务器是否可行

drm - 是否有可用的免费 PlayReady 服务器?

javascript - 需要帮助使用 javascript 更改 html 5 视频的宽度或高度

html - 嵌入 youtube html5 播放器显示没有全屏按钮