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

Nginx nginx-rtmp-module 直播推流 配置

时间:2021-06-13 09:55:40      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:wait   空闲   info   error   als   base   process   ati   数据   




nginx.conf配置
#user  nobody;
user www www;
worker_processes  8;

#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 配置
rtmp {  
    server {  
      listen 1935;      #监听的端口号
          chunk_size 4096;  #数据传输块的大小
          application experienceApp {  #rtmp推流请求路径  
          live on;
           drop_idle_publisher 5s;      #5s时间内丢弃空闲的publisher
        }

        application hls {               #rtmp推流请求路径  
            live on;  
            hls on;                     
            drop_idle_publisher 5s;     #5s时间内丢弃空闲的publisher
            wait_key on;                #使视频流开始一个关键帧。默认为关闭。
            hls_path /tmp/hls;          #视频存放地址
            hls_fragment 10s;           #每个视频切片的时长。
            hls_playlist_length 60s;    #总共可以回看的事件,这里设置的是1分钟。
            hls_continuous on;          #连续模式。
            hls_cleanup on;             #对多余的切片进行删除。
            hls_nested on;              #打开后的作用是每条流自己有一个文件夹
        }  
    } 
}

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_tokens off;

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    server {
        listen       80;
        add_header Access-Control-Allow-Origin *;

    #HLS配置开始,这个配置为了客户端能够以http协议获取HLS的拉流
        location /hls {
            add_header Access-Control-Allow-Origin *;
            types {  
                application/vnd.apple.mpegurl m3u8;  
                video/mp2t ts;  
            }
            root /tmp;  #跟上面的hls_path路径对应
            expires -1; 
            #防止跨域问题
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Credentials true;
            add_header Access-Control-Allow-Methods GET, POST, OPTIONS;
            add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;
        } 

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
           root /usr/local/nginx/modules/nginx-rtmp-module-master/;
        }

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

    # 引入域名的配置
    include vhosts/*.conf;
}

 

  

Nginx nginx-rtmp-module 直播推流 配置

标签:wait   空闲   info   error   als   base   process   ati   数据   

原文地址:https://www.cnblogs.com/crow9527/p/14877737.html

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