1.获取nginx-rtmp-module
git clone https://github.com/arut/nginx-rtmp-module.git
- 编译添加模块
configure文件目录在nginx根目录下
添加这个--with-cc-opt="-Wimplicit-fallthrough=0" 否则报错
sudo ./configure --prefix=/usr/local/nginx --with-cc-opt="-Wimplicit-fallthrough=0" --add-module=/home/soap/rtmp/nginx-rtmp-module/
4.修改nginx.conf http模块添加配置
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /home/soap/rtmp/nginx-rtmp-module/;
}
location /hls { #这里也是需要添加的字段。
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /home/soap/rtmp/hls;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
}
5.单独模块
rtmp {
server {
listen 1935; #监听的端口
chunk_size 4000;
application myapp {
live on;
}
application hls {
live on;
hls on;
hls_path /home/soap/rtmp/hls;#视频流存放地址
hls_fragment 5s;
hls_playlist_length 15s;
hls_continuous on; #连续模式。
hls_cleanup on; #对多余的切片进行删除。
hls_nested on; #嵌套模式。
}
}
}
6.推流下载obs或者ffmpge
7.拉流下载 vlc
来源:oschina
链接:https://my.oschina.net/findurl/blog/4497231