我已经安装了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碎片”.
最佳答案 为了从像mp4这样的静态文件动态创建ts段,文件名和扩展名必须存在于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