2

看起来 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 标签:https ://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming-08 #section-6.3.3

所以我猜这是苹果自己的规范的实现是错误的,但也许是我做错了。

我制作了一个快速的 html 页面来测试它(在任何 ios5 设备上的 safari 中打开它):http: //ixemes-ppweb.ixemes.com/prerollmain/index.html

4

2 回答 2

2

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

于 2015-02-14T01:11:44.627 回答
1

好的,看起来它与主视频的加密无关,而与主视频的编码方式有关。我无法控制主视频的编码方式。我只对自己的预卷视频进行编码(并分块)以进行测试。

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

但是,如果我对自己的两个视频(前卷和主视频)进行编码,加密主视频,并使用不连续性标签将它们放入单个 m3u8 文件中,它就可以工作。

所以 ios 处理不连续性标签的方式仍然存在问题,并且没有完全重置播放器参数,但至少可以在加密的前卷视频之前插入未加密的预卷视频。

于 2012-07-25T13:59:48.353 回答