如果.TS文件名中有空格,则HLS流式传输将不起作用

时间:2018-08-27 07:53:18

标签: ios url-encoding hls m3u8

我正在用iOS应用程序实现HLS,我可以播放大多数网址。尽管某些主索引文件网址,子索引文件网址和.ts文件网址包含空格,但如果出现以下情况,Avplayer将无法播放网址中有空格。

我可以编码主索引文件url,然后如何强制AVPlayer编码子索引文件url和.ts文件url?

主播放列表URL看起来像这样(编码之前):

https://cfsigned.xxxxxxxxxxxx.com/MP4/default/Project_Management/Introduction_to_Project_Management/Lesson 02-项目管理技巧-概述/2.003_Project Selection Techniques.m3u8

以下是主播放列表内容:

#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-0",NAME="Default",AUTOSELECT=YES,DEFAULT=YES,URI="audio/2.003_Project Selection     Techniques1351620000001-200071_m4a_v4.m3u8"
#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=10152000,CODECS="avc1.42001e",URI="480/2.003_Project Selection     Techniques1351620000001-200055_mp4_iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=13806000,CODECS="avc1.42001e",URI="720/2.003_Project Selection     Techniques1351620000001-200045_mp4_iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=16559000,CODECS="avc1.4d001e",URI="1080/2.003_Project Selection    Techniques1351620000001-200035_mp4_iframe.m3u8"
#EXT-X-I-FRAME-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=24004000,CODECS="avc1.4d001f",URI="1080/2.003_Project Selection    Techniques1351620000001-200025_mp4_iframe.m3u8"

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=261000,RESOLUTION=400x224,CODECS="avc1.42001e,mp4a.40.5",AUDIO="audio-0"
480/2.003_Project Selection Techniques1351620000001-200055_mp4_v4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=307000,RESOLUTION=480x270,CODECS="avc1.42001e,mp4a.40.5",AUDIO="audio-0"
720/2.003_Project Selection Techniques1351620000001-200045_mp4_v4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=382000,RESOLUTION=640x360,CODECS="avc1.4d001e,mp4a.40.5",AUDIO="audio-0"
1080/2.003_Project Selection Techniques1351620000001-200035_mp4_v4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=613000,RESOLUTION=960x540,CODECS="avc1.4d001f,mp4a.40.5",AUDIO="audio-0"
1080/2.003_Project Selection Techniques1351620000001-200025_mp4_v4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=72000,CODECS="mp4a.40.5",AUDIO="audio-0"
audio/2.003_Project Selection Techniques1351620000001-200071_m4a_v4.m3u8

第一个子索引文件的内容::480 / 2.003_项目选择技术1351620000001-200055_mp4_v4.m3u8

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:13
#EXTINF:12.0,
#EXT-X-BYTERANGE:208868@0
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:11.999999999999998,
#EXT-X-BYTERANGE:149084@208868
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:149084@357952
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:183676@507036
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:191384@690712
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.000000000000007,
#EXT-X-BYTERANGE:186872@882096
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:218268@1068968
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:283692@1287236
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:261696@1570928
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:12.0,
#EXT-X-BYTERANGE:245716@1832624
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXTINF:11.900000000000006,
#EXT-X-BYTERANGE:240640@2078340
2.003_Project Selection Techniques1351620000001-200055_mp4.ts
#EXT-X-ENDLIST

如您所见,.ts文件名的名称中有空格。

一种解决方案是在生成播放列表文件时删除/编码空格。

但是由于一些内部问题,目前无法实现此解决方案。

PS:在 Android 上,一切都只能在无法正常运行的ios上正常运行

0 个答案:

没有答案