nginx-http-flv-module

nginx-http-flv-module是基于nginx-rtmp-module的流媒体服务器。

安装

  • 安装依赖

    [CentOS7]

    yum install -y pcre pcre-devel zlib zlib-devel gcc-c++ openssl openssl-devel

    [Ubuntu]

    sudo apt-get install build-essential libtool libpcre3 libpcre3-dev zlib1g-dev openssl
  • 编译安装

    ./configure --with-http_ssl_module --add-module=/path/to/nginx-http-flv-module
    make
    make install

配置

  • http-flv/http-flv.conf

    server {
        # set according to your environment
        listen 8080;
        server_name localhost;
    
        location /live {
            flv_live on;
            chunked_transfer_encoding  on;
    
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
        }
    }
  • http-flv/rtmp.conf

    #because the vhost feature is not perfect in multi-processes
    #mode yet, the directive worker_processes should be set to 1
    
    rtmp_auto_push on;
    rtmp_auto_push_reconnect 1s;
    rtmp_socket_dir /tmp;
    
    rtmp {
        out_queue    4096;
        out_cork     8;
        max_streams  256;
        timeout      15s;
        drop_idle_publisher 15s;
    
        server {
            # set according to your environment
            # listen 1935;
            # server_name localhost;
    
            application myapp {
                live on;
                gop_cache on;
            }
    
            application hls {
                live on;
                hls on;
                hls_path /tmp/hls;
            }
    
            application dash {
                live on;
                dash on;
                dash_path /tmp/dash;
            }
        }
    }
  • nginx.conf

    .....
    include http-flv/rtmp.conf;
    ....
    http {
    ....
        include http-flv/http-flv.conf;
    ....
    }

最后更新于