nginx rtmp 应用层协议
Posted weedsyl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx rtmp 应用层协议相关的知识,希望对你有一定的参考价值。
1,安装nginx-rtmp-module模块
配置文件 open /usr/local/etc/nginx 下的nginx.conf
#配置nginx支持rtmp sudo vim /usr/local/nginx/conf/nginx.conf rtmp { server{ listen 1066; #录制配置 record all; record_unique on; record_path /home/weeds/weeds/rtmp/record; record_suffix -%Y-%m-%d-%H_%M_%S.flv; #record_max_size 300m; #直播权限配置 publish_notify on; #notify_method get; on_publish http://dev.ft.com/new_api/huazhen_rtmp/pushCallBack; #on_publish_done http://127.0.0.1/publishDoneCallBack.php; #on_play http://127.0.0.1/playCallBack.php; #on_play_done http://127.0.0.1/playDoneCallBack.php; #直播流配置 application rtmplive{ live on; #为rtmp设置最大链接数。默认为off max_connections 1024; } application hls{ live on; #hls on; #hls_path /home/weeds/weeds/rtmp/hls; #hls_fragment 5s; } hls on; hls_path /home/weeds/weeds/rtmp/hls; hls_fragment 5s;#没有生效 hls_playlist_length 30s; hls_nested on; #默认是off。打开后的作用是每条流自己有一个文件夹 hls_cleanup off;#不清理ts } } #nginx配置支持hls http节点的server下增加 #加入hls支持 location /hls { types { application/vnd.apple.mpegurl m3u8; #或 application/x-mpegURL video/mp2t ts; } alias /home/weeds/weeds/rtmp/hls; #视频流文件目录(自己创建) expires -1; add_header Cache-Control no-cache; } #end... #重启nginx sudo /usr/local/nginx/sbin/nginx -s reload #推流 ffmpeg -re -i /home/weeds/weeds/audio/4.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1066/hls/room http://localhost/hls/room/index.m3u8
参考文档
https://github.com/arut/nginx-rtmp-module/wiki/Directives
以上是关于nginx rtmp 应用层协议的主要内容,如果未能解决你的问题,请参考以下文章
HLS NGINX-RTMP [错误] 1281#0:* 58 hls:强制片段拆分:10.002 秒