我已经安装了Nginx Plus并为流媒体配置了HLS。在请求m3u8
文件时,我收到错误:
2015/09/29 13:32:34 [error] 5814#5814: *1 open() "/usr/video/hls/CODECS="avc1.42e00a,mp4a.40.2"" failed (2: No such file or directory)
m3u8
文件包含以下内容:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=545600,RESOLUTION=416x234,CODECS="avc1.42e00a,mp4a.40.2"
/usr/video/hls/myvideo_low.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
/usr/video/hls/myvideo_high.m3u8
Nginx配置是:
location /hls {
root /usr/video;
hls;
hls_fragment 5s;
hls_buffers 10 10m;
hls_mp4_buffer_size 1m;
hls_mp4_max_buffer_size 5m;
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Cache-Control' 'no-cache';
}
在浏览器中,我收到警告: "未发现TS片段"。
答案 0 :(得分:2)
为了从ts
这样的静态文件动态创建mp4
段,文件名和扩展名必须出现在m3u8
播放列表文件名中:
myvideo_high.mp4.m3u8
的 myvideo_high.mp4
有关:
myvideo_high.m3u8
它假设细分已经存在。
Serving Media with NGINX Plus白皮书显示了手动创建的m3u8
变体播放列表的示例,由于页面格式化(换行),不正确:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=545600,RESOLUTION=416x234,
CODECS="avc1.42e00a,mp4a.40.2"
/hls/myvideo_low.mp4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,RESOLUTION=640x360,
CODECS="avc1.42e00a,mp4a.40.2"
/hls/myvideo_high.mp4.m3u8
#EXT-X-STREAM-INF
信息应该在一行上(没有换行符):
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=545600,RESOLUTION=416x234,CODECS="avc1.42e00a,mp4a.40.2"
/hls/myvideo_low.mp4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
/hls/myvideo_high.mp4.m3u8