Nginx流直播模块nginx-http-flv-module配置

编译安装

./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx  --with-http_ssl_module --with-openssl=/usr/local/openssl --with-http_stub_status_module  --add-module=../nginx-http-flv-module-master

make && make install

 

    server {
        server_name  127.0.0.1;
        listen 8038;
        location /edgecameralive {
        #location / {
                add_header Cache-Control no-cache;
                add_header 'Access-Control-Allow-Origin' '*' always;
                add_header 'Access-Control-Expose-Headers' 'Content-Length';
                if ($request_method = 'OPTIONS') {
                    add_header 'Access-Control-Allow-Origin' '*';
                    add_header 'Access-Control-Max-Age' 1728000;
                    add_header 'Content-Type' 'text/plain charset=UTF-8';
                    add_header 'Content-Length' 0;
                    return 204;
                }
                types {
                    application/vnd.apple.mpegurl m3u8;
                    video/mp2t ts;
                }
                alias /home/gpmonitor_shipin/hls/;
        }
        location /live {
            flv_live on; #open flv live streaming (subscribe)
            chunked_transfer_encoding  on; #open 'Transfer-Encoding: chunked' response
            add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header
            add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header
         }
         location /stat {
                 #configuration of streaming & recording statistics
                 rtmp_stat all;
             rtmp_stat_stylesheet stat.xsl;
          }
         location /stat.xsl {
                 #root /root/nginx-http-flv-module-master/; #该路径修改为自己nginx-http-flv-module模块路径(stat.xsl的所在目录)
                 root /home/gpmonitor_shipin/hls/; #该路径修改为自己nginx-http-flv-module模块路径(stat.xsl的所在目录,从源码中拷贝这个文件到该路径下)
          }
     }
}

# rtmp 配置在 http 外面
rtmp {
    server {
        listen 1935;
        chunk_size 4000;
        application live {
            live on;
            record off;
        }
        application edgecameralive {
            live on;
            hls on;
            hls_path /home/gpmonitor_shipin/hls;
            hls_fragment 1;
            hls_playlist_length 5;
            deny play all;
            record all;
            record_unique on;
            record_path /home/gpmonitor_shipin/record;
            record_suffix -%Y-%m-%d-%H_%M_%S.flv;
        }
    }
}

 

posted @ 2022-09-08 09:23  linyouyi  阅读(1512)  评论(0编辑  收藏  举报