nginx-http-flv編譯配置

編譯

在這裏插入圖片描述

./configure --prefix=./_install --add-module=../nginx-http-flv-module 

修改中間目錄

在這裏插入圖片描述
在這裏插入圖片描述

修改配置

vim _install/conf/nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;
        application live {
            live on;
            record off;
        }
    }
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8008;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        location /live {
            flv_live on;
            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 push & pull status

            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html; #specify in where stat.xsl located
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

啓動

don@server-01:~/nginx-http-flv/nginx-1.14.2/_install$ cp sbin/nginx ./
don@server-01:~/nginx-http-flv/nginx-1.14.2/_install$ ./nginx -c conf/nginx.conf

預覽

推流url

rtmp://ip:1935/live/live_stream

拉流

vlc

http://ip:8008/live?port=1935&app=live&stream=live_stream

flv.js

在這裏插入圖片描述
注意這裏要勾選isLive

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章