似乎ios不喜欢将加密的.ts文件与EXT-X-DISCONTINUITY标签混合在一起的hls m3u8文件。
这是一个测试播放列表,它是两个视频的混合。未加密的前置广告和主要加密的视频。两者都表现得很好,但是当我将它们放在一个由EXT-X-DISCONTINUITY分隔的m3u8中时,只播放预卷,然后播放器停止。
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/vig_400-0.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/vig_400-1.ts
#EXT-X-DISCONTINUITY
#EXTINF:10,
#EXT-X-KEY:METHOD=AES-128,URI="http://ixemes-ppweb.ixemes.com/prerollmain/113760.key"
http://ixemes-ppweb.ixemes.com/prerollmain/02-0.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-1.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-2.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-3.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-4.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-5.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-6.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-7.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-8.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-9.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-10.ts
#EXTINF:10,
http://ixemes-ppweb.ixemes.com/prerollmain/02-11.ts
#EXTINF:2,
http://ixemes-ppweb.ixemes.com/prerollmain/02-12.ts
#EXT-X-ENDLIST
我尝试了两个未加密的视频,并且可以正常工作。而且我在HLS规范中看不到任何禁止使用EXT-X-DISCONTINUITY标签和加密视频的内容:http://tools.ietf.org/html/draft-pantos-http-live-streaming-08#section-6.3.3
所以我想这是苹果自己的规范实现,这是错误的,但也许是我做错了。
我做了一个快速的html页面来测试它(在任何ios5设备上的safari中打开它):http://ixemes-ppweb.ixemes.com/prerollmain/index.html
最佳答案
我注意到您的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显式设置为“0x00000000000000000000000000000000000001”,如下所示:
#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。所以也许这就是您遇到的问题。
关于ios - 在iOS上的EXT-X-DISCONTINUITY标签之后无法播放hls aes加密视频,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11562150/