在ios上的EXT-X-DISCONTINUITY标签之后,没有播放加密的视频

时间:2012-07-19 13:39:55

标签: ios ios5 http-live-streaming

看起来ios不喜欢将加密的.ts文件与EXT-X-DISCONTINUITY标签混合的hls m3u8文件。

这是一个测试播放列表,它是两个视频的混合。未加密的预卷广告和主加密视频。两者都很好地分开,但是当我把它们放在一个m3u8中,由EXT-X-DISCONTINUITY分开时,只播放预卷,然后播放器停止。

#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

2 个答案:

答案 0 :(得分:2)

我注意到你的EXT-X-KEY没有IV术语,a.k.a。是一个初始化向量。标准支持这一点,例如:

#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:

  

媒体加密的默认初始化向量(如果没有   指定的)是媒体文件的序列号。你应该   指定初始化向量值,而不依赖于序列   数字。其主要原因是便携性。例如,如果你   改变片段在播放列表中出现的位置(例如插入一个   ad),它改变了它的序列号,需要重新加密。

在我的团队中,我们无法弄清楚为什么插入广告的加密内容没有播放。我们有一个加密内容的例子:

#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

此网址为http://demo.theplatform.com/dev/m3u8/mix.m3u8。我们发现问题是因为我们添加了两个段,媒体序列号现在关闭了2.如果你明确地将IV设置为“0x00000000000000000000000000000001”,就像这样:

#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。所以也许这就是你遇到的问题。

答案 1 :(得分:1)

好吧,看起来它与主视频的加密无关,但主要视频的编码方式更多。我无法控制主视频的编码方式。我只对自己的预卷视频进行编码(并且自我测试)以进行测试。

如果我将预卷与同一主视频混合但未加密,则它也不起作用。 如果我混合两个由相同的外部编码器编码的视频,加密(或不加密)它不起作用。 不知道编码外部编码器的参数有什么问题,但是不连续性标签不起作用。

但是,如果我自己编码视频(preroll和main),加密主视频,并使用不连续标签将它们放在一个m3u8文件中,它就可以工作。

因此,ios如何处理不连续标记并且没有完全重置播放器参数仍有问题,但至少可以在加密前插入未加密的预卷视频。< / p>