我注意到您的 EXT-X-KEY 没有 IV 项,即初始化向量。标准支持这一点,例如:
#EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=52",IV=0x9c7db8778570d05c3177c349fd9236aa
如果缺少,以下是https://developer.apple.com/library/ios/technotes/tn2288/_index.html说玩家应该选择 IV:
媒体加密的默认初始化向量(如果未指定)是媒体文件的序列号。您应该指定一个初始化向量值,而不是依赖于序列号。主要原因是便携性。例如,如果您更改片段在播放列表中的显示位置(例如插入广告),则会更改其序列号,需要重新加密。
在我的团队中,我们无法弄清楚为什么带有插入广告的加密内容无法播放。我们有一个播放的加密内容示例:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=AES-128,URI="http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key"
#EXTINF:11,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-1.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-2.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-3.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-4.ts
#EXTINF:10,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-5.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-6.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-7.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-8.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-9.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-10.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-11.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-12.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-13.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-14.ts
#EXTINF:5,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-15.ts
#EXT-X-ENDLIST
你可以在http://demo.theplatform.com/dev/m3u8/encrypted.m3u8试试这个。但是当我们在它之前插入内容时,就像这样,它没有播放:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=NONE
#EXTINF:10.01,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00001.ts
#EXTINF:5.088,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00002.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=AES-128,URI="http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key"
#EXTINF:11,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-1.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-2.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-3.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-4.ts
#EXTINF:10,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-5.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-6.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-7.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-8.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-9.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-10.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-11.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-12.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-13.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-14.ts
#EXTINF:5,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-15.ts
#EXT-X-ENDLIST
这个 URL 是http://demo.theplatform.com/dev/m3u8/mix.m3u8。我们发现问题是因为我们添加了两个段,媒体序列号现在减少了 2。如果您明确地将 IV 设置为“0x000000000000000000000000000000001”,如下所示:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-KEY:METHOD=NONE
#EXTINF:10.01,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00001.ts
#EXTINF:5.088,
http://ne.edgecastcdn.net/0008B0/mps/Inkola_VMS/20/687/15_WordIsOut_UPFW1764H_1080p_20802040_m3u8_video_480x0_400000_primary_audio_eng_2_x5e1c9dd7b9834f38a319d348e1a5f9ee_00002.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=AES-128,URI="http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key",IV=0x00000000000000000000000000000001
#EXTINF:11,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-1.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-2.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-3.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-4.ts
#EXTINF:10,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-5.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-6.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-7.ts
#EXTINF:7,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-8.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-9.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-10.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-11.ts
#EXTINF:8,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-12.ts
#EXTINF:6,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-13.ts
#EXTINF:9,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-14.ts
#EXTINF:5,
http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=2042000-15.ts
#EXT-X-ENDLIST
然后它工作。你可以试试这个http://demo.theplatform.com/dev/m3u8/mix_fixed.m3u8。所以也许这就是你遇到的问题。