为什么赢了';在iOS上播放加密的HLS视频(但可以通过HLS.js库在Windows Chrome上运行)?

为什么赢了';在iOS上播放加密的HLS视频(但可以通过HLS.js库在Windows Chrome上运行)?,ios,video,ffmpeg,http-live-streaming,Ios,Video,Ffmpeg,Http Live Streaming,原始视频是来自的“示例视频5” 我的/home/vagrant/code/example/public/hls\u hls.keyInfo是: https://example.com/hls.key /home/vagrant/Code/example/public/hls_hls.key 467216aae8a26fb699080812628031955e304a66e9e4480f9b70d31d8fe94e9a 我的/home/vagrant/code/example/public/hl

原始视频是来自的“示例视频5”

我的
/home/vagrant/code/example/public/hls\u hls.keyInfo
是:

https://example.com/hls.key
/home/vagrant/Code/example/public/hls_hls.key
467216aae8a26fb699080812628031955e304a66e9e4480f9b70d31d8fe94e9a
我的
/home/vagrant/code/example/public/hls_hls.key
是使用PHP生成的:
hex2bin('467216aae8a26fb699080812628031955e304a66e9e4480f9b70d31d8fe94e9a')

使用“ts”文件将视频加密为HLS播放列表的命令:

然后,我知道如果没有库,Windows Chrome将无法播放HLS视频,因此我使用,Windows Chrome成功地播放了加密视频

但是,iOS Safari无法播放它(有或没有hls.js库)。

在iOS Safari上,当我尝试播放视频时,我只看到一个快速的一瞥(不到一秒),屏幕显示0:15,因此它必须读取和解密足够多的内容,才能知道视频的正确持续时间。

因此,要进行调试,我需要记录事件:

const nativeHlsEvents = ['play', 'playing', 'abort', 'error', 'canplaythrough', 'waiting', 'loadeddata', 'loadstart', 'progress', 'timeupdate', 'volumechange'];
$.each(nativeHlsEvents, function (i, eventType) {
    video.addEventListener(eventType, (event) => {//https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
        console.log(eventType, event);
        if (eventType === 'error') {
            console.error(video.error);//https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/error
        }
    });
});
我在控制台日志中看到:

loadstart, {"isTrusted":true}
progress, {"isTrusted":true}
play, {"isTrusted":true}
waiting, {"isTrusted":true}
error, {"isTrusted":true}
video.error, {}
{"type":"mediaError","details":"fragParsingError","fatal":false,"reason":"TS packet did not start with 0x47","frag":{"...
{"type":"mediaError","details":"fragParsingError","fatal":false,"reason":"no audio/video samples found","frag":{...
我不知道如何找到关于这个错误的更多细节

请注意,即使Windows Chrome成功播放视频,它也会在控制台日志中显示警告:

loadstart, {"isTrusted":true}
progress, {"isTrusted":true}
play, {"isTrusted":true}
waiting, {"isTrusted":true}
error, {"isTrusted":true}
video.error, {}
{"type":"mediaError","details":"fragParsingError","fatal":false,"reason":"TS packet did not start with 0x47","frag":{"...
{"type":"mediaError","details":"fragParsingError","fatal":false,"reason":"no audio/video samples found","frag":{...

我的问题在哪里?

我需要买一部更新的iPhone。


我看到“6s”是iOS 13支持的最古老的硬件,并且说HLS需要>=13.2

Iphone设备不支持媒体源扩展

您应该通过用户代理检查是否有iphone


如果正确的话,您应该使用iphone本机视频播放器播放hls视频类型或更多视频类型

我现在问了应该使用什么加密方法: