宝塔安装nginx-http-flv-module,音视频直播,第二篇

1,先安装环境安装nginx

先卸载原有nigix
nigix 大于等于 1.2.6
cd /www/server  # 进入宝塔目录 
yum install git -y
git clone https://gitee.com/winshining/nginx-http-flv-module.git
使用源码安装nigix
在 自定义模块 区域点击「添加」,填写以下参数:
模块名称:http_flv 
描述:http_flv
参数:--add-module=/www/server/nginx-http-flv-module

记得启动,后安装

2,修改配置

创建文件   /www/server/nginx/conf/rtmp.conf 
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp {
    out_queue 4096;
    out_cork 8;
    max_streams 64;
    #Nginx能接受的最大的推流数
    timeout 15s;
    drop_idle_publisher 15s;
    log_interval 5s;
    server {
        listen 1935;
        chunk_size 4096;
        log_size 1m;
        #HLS 直播流配置
        application hls {
            live on;
            hls on;
            hls_path /www/wwwroot/SeaCMS/hls;
            #HLS视频流存放地址
            hls_sync 100ms;
            hls_fragment 3s;
            hls_playlist_length 10s;
            hls_continuous on;
            #连续模式。
            hls_cleanup on;
            #对多余的切片进行删除。
            hls_nested on;
            #嵌套模式。
        }
        #DASH 直播流配置
        application dash {
            live on;
            dash on;
            dash_path /www/wwwroot/SeaCMS/dash;
            #DASH视频流存放地址
            dash_nested on;
            dash_fragment 3s;
            dash_playlist_length 10s;
        }
        application live {
            live on;
            gop_cache on;
            #开启GOP缓存,播放解码时收到完整的GOP才开始播放,减少延迟的选项
        }
    }
}
打开 /www/server/nginx/conf/nginx.conf 
引入配置文件 include rtmp.conf; 

宝塔安装nginx-http-flv-module,音视频直播,第二篇_第1张图片

3,进行推流实验

宝塔和服务器都放行,1935端口
推流工具(OBS)设置:
服务器地址:rtmp://你的服务器IP:1935/live
流密钥:自定义(如 test)912。
播放测试:
RTMP 协议:rtmp://服务器IP:1935/live/test
flv 协议:这个有问题应该是安装 nginx 的问题,今天时间不够了,回头再写
播放正常

你可能感兴趣的:(nginx,http,音视频)