NGINX配置rtmp块只需要配置一个application就可以了
application myapp {
live on;//开启直播
gop_cache on;
hls on;//开启切片
hls_path /usr/local/nginx/myapp;//切片存放路径
}
使用OBS推流
rtmp://example.com[:port]/appname/streamname
http-flv播放形式:(配合bilibili的flv.js播放)
http://example.com[:port]/dir?[port=xxx&]app=appname&stream=streamname
需要配置dir为http块中location的对应块,块中要标明下列等信息
flv_live on;
chunked_transfer_encoding on;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
RTMP播放形式:(VLC media player可以播放)
rtmp://example.com[:port]/appname/streamname
HLS播放方式:(VLC media player可以播放)
http://example.com[:port]/dir/streamname.m3u8
需要配置dir为http块中location的对应块,块中要标明
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias /usr/local/nginx/myapp;
add_header 'Cache-Control' 'no-cache';
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
videojs可以播放rtmp和hls