码迷,mamicode.com
首页 > 其他好文 > 详细

nginx rtmp 应用层协议

时间:2019-10-10 11:03:29      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:aac   模块   协议   pat   没有   play   文档   cal   llb   

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 应用层协议

标签:aac   模块   协议   pat   没有   play   文档   cal   llb   

原文地址:https://www.cnblogs.com/weedsyl/p/11646178.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!