美文网首页
nginx rtmp推流,rtmp+flv+hls(m3u8)同

nginx rtmp推流,rtmp+flv+hls(m3u8)同

作者: Mracale | 来源:发表于2024-05-28 17:07 被阅读0次
image.png

服务器:rtmp://ip:80/live
推流码:summer

rtmp拉流地址:rtmp://ip/live/summer
http-flv拉流地址:http://ip:80/flv_live?port=1935&app=live&stream=summer
hls-m3u8拉流地址:http://ip:80/hls/summer.m3u8


#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;
}

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       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location /hls {
            types {
                  application/vnd.apple.mpegurl m3u8;
                  video/mp2t ts;
                }
            alias /usr/share/nginx/html/hls;   
            expires -1;
            add_header 'Cache-Control' 'no-cache'; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
rtmp {
    server {
            listen 1935;
            chunk_size 4096;
            application live {
                    live on;
                    record off;
            hls on;
            hls_path /usr/share/nginx/html/hls;
            hls_fragment 2s;
                    #exec ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name;

            }

            application live360p {
                    live on;
                    record off;
            }
            application hls360p {
                live on;
                hls on;
                hls_path /usr/share/nginx/html/hls2;
                hls_fragment 2s;

            }
    }
}

相关文章

网友评论

      本文标题:nginx rtmp推流,rtmp+flv+hls(m3u8)同

      本文链接:https://www.haomeiwen.com/subject/pofkqjtx.html