技术类 Nginx Nginx 使用 rtmp 模块 双木老林 2020-07-23 2021-03-09
该备忘配置参考于 搭建Nginx+nginx-rtmp-module的hls流媒体服务器并用OBS进行推流
Nginx 编译 首先 nginx 需要安装 rtmp 模块
1 2 3 4 cd /home/nginxgit clone https://github.com/arut/nginx-rtmp-module ./configure --prefix=/usr/local/nginx --add-module=/home/nginx/nginx-rtmp-module --with-http_ssl_module make && make install
增加配置 vim /usr/local/nginx/conf/nginx.conf
与 http {} 同级
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 rtmp { server { listen 1935; chunk_size 4096; application hls { live on; hls on; hls_path /tmp/hls; hls_fragment 5s; hls_playlist_length 15s; hls_continuous on; hls_cleanup on; hls_nested on; } } }
启动 nginx
推流 常用的是 ffmpeg 或者各种开源软件,在 github 上搜一下推流
往 rtmp://ip:1935/hls[/name] 上推流即可
[/name] 指的可以不要这一块,也可以要。两者的区别就是在服务器中生成 m3u8 的地址不同,不填的时候就在 /tmp/hls,如果填了 /abc,则会生成在 /tmp/hls/abc
拿流 往拿推就往拿哪