2017-08-15 119 views
1

我是新来的Stackoverflow,这将是我的第一个问题。我的HTML5播放器在Internet Explorer上正常工作,但不适用于谷歌浏览器。我正在使用用CENC加密的PlayReady流。我如何让这个工作在Chrome上进行?我无法访问服务器,它们由第三方运行。HTML5 player not working on chrome

感谢

+0

请发布您的代码。 – anu

回答

2

技术上讲,它可以支持的Widevine,而你流的PlayReady。这是可能的,因为你使用CENC。由于您无法访问像您提到的服务器,因此可以使用称为PSSH Forging的技术。它基本上取代了这些部分,使得Chrome认为它是Widevine,因为它是CENC,CDM将解密视频并且将播放流。

为了方便起见,我假设你使用DASH。

我们这里有一个PSSH箱:

const widevinePSSH = '0000005c7073736800000000edef8ba979d64acea3c827dcd51d21ed0000003c080112101c773709e5ab359cbed9512bc27755fa1a087573702d63656e63221848486333436557724e5a792b32564572776e64562b673d3d2a003200'; 

你需要用你的孩子来代替1c773709e5ab359cbed9512bc27755fa

然后在您插入找你的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; 

遗憾的是我只能分享的点点滴滴,但是这大致就是你应该做到让它工作。