winshining / nginx-http-flv-module

A media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module provides, HTTP-FLV, GOP cache, VHosts (one IP for multi domain names) and JSON style statistics are supported now.
BSD 2-Clause "Simplified" License
2.72k stars 567 forks source link

nginx 1.19 + nginx-http-flv-module ,HLS,DASH 流数据无法形成,在/tmp/hls ,/tmp/dash 目录下无文件生成,rtmp,http-flv 都能正常使用 #171

Closed yjjie closed 4 years ago

yjjie commented 4 years ago

Expected behavior / 期望行为

rtmp , http-flv , hls ,dash 都能正常拉取

Actual behavior / 实际行为

hls ,dash 没有

OS and Nginx version / 操作系统和Nginx版本号

nginx 1.19

Configuration file / 配置文件

Steps to reproduce the behavior / 复现问题步骤

winshining commented 4 years ago

1

请保证你的配置是正确的。

yjjie commented 4 years ago

`#worker_processes 1; #运行在Windows上时,设置为1,因为Windows不支持Unix domain socket worker_processes auto; #1.3.8和1.2.5以及之后的版本

worker_cpu_affinity 0001 0010 0100 1000; #只能用于FreeBSD和Linux

worker_cpu_affinity auto; #1.9.10以及之后的版本

error_log logs/error.log error;

如果此模块被编译为动态模块并且要使用与RTMP相关的功

能时,必须指定下面的配置项并且它必须位于events配置

项之前,否则NGINX启动时不会加载此模块或者加载失败

load_module modules/ngx_http_flv_live_module.so;

events { worker_connections 4096; }

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

keepalive_timeout  65;

server {
    listen       8080;

    location / {
        root   /var/www/huimv;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location /live {
        flv_live on; #打开HTTP播放FLV直播流功能
        chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回复

        add_header 'Access-Control-Allow-Origin' '*'; #添加额外的HTTP头
        add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的HTTP头
    }

    location /hls {
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }

        root /tmp;
        add_header 'Cache-Control' 'no-cache';
    }

    location /dash {
        root /tmp;
        add_header 'Cache-Control' 'no-cache';
    }

    location /stat {
        #push和pull状态的配置

        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl {
        root /var/www/rtmp; #指定stat.xsl的位置
    }

    #如果需要JSON风格的stat, 不用指定stat.xsl
    #但是需要指定一个新的配置项rtmp_stat_format

    #location /stat {
    #    rtmp_stat all;
    #    rtmp_stat_format json;
    #}

    location /control {
        rtmp_control all; #rtmp控制模块的配置
    }
}

}

rtmp_auto_push on; rtmp_auto_push_reconnect 1s; rtmp_socket_dir /tmp;

rtmp { out_queue 4096; out_cork 8; max_streams 128; timeout 15s; drop_idle_publisher 15s;

log_interval 5s; #log模块在access.log中记录日志的间隔时间,对调试非常有用
log_size     1m; #log模块用来记录日志的缓冲区大小

server {
    listen 1935;
    #server_name www.test.*; #用于虚拟主机名后缀通配

    application live {
        live on;
        gop_cache on; #打开GOP缓存,减少首屏等待时间
    }

    application hls {
        live on;
        hls on;
        hls_path /tmp/hls;
    }

    application dash {
        live on;
        dash on;
        dash_path /tmp/dash;
    }
}

} ` 老大帮我检查下

kay1ess commented 4 years ago

`#worker_processes 1; #运行在Windows上时,设置为1,因为Windows不支持Unix domain socket worker_processes auto; #1.3.8和1.2.5以及之后的版本

worker_cpu_affinity 0001 0010 0100 1000; #只能用于FreeBSD和Linux

worker_cpu_affinity auto; #1.9.10以及之后的版本

error_log logs/error.log error;

如果此模块被编译为动态模块并且要使用与RTMP相关的功

能时,必须指定下面的配置项并且它必须位于events配置

项之前,否则NGINX启动时不会加载此模块或者加载失败

load_module modules/ngx_http_flv_live_module.so;

events { worker_connections 4096; }

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

keepalive_timeout  65;

server {
    listen       8080;

    location / {
        root   /var/www/huimv;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location /live {
        flv_live on; #打开HTTP播放FLV直播流功能
        chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回复

        add_header 'Access-Control-Allow-Origin' '*'; #添加额外的HTTP头
        add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的HTTP头
    }

    location /hls {
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }

        root /tmp;
        add_header 'Cache-Control' 'no-cache';
    }

    location /dash {
        root /tmp;
        add_header 'Cache-Control' 'no-cache';
    }

    location /stat {
        #push和pull状态的配置

        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl {
        root /var/www/rtmp; #指定stat.xsl的位置
    }

    #如果需要JSON风格的stat, 不用指定stat.xsl
    #但是需要指定一个新的配置项rtmp_stat_format

    #location /stat {
    #    rtmp_stat all;
    #    rtmp_stat_format json;
    #}

    location /control {
        rtmp_control all; #rtmp控制模块的配置
    }
}

}

rtmp_auto_push on; rtmp_auto_push_reconnect 1s; rtmp_socket_dir /tmp;

rtmp { out_queue 4096; out_cork 8; max_streams 128; timeout 15s; drop_idle_publisher 15s;

log_interval 5s; #log模块在access.log中记录日志的间隔时间,对调试非常有用
log_size     1m; #log模块用来记录日志的缓冲区大小

server {
    listen 1935;
    #server_name www.test.*; #用于虚拟主机名后缀通配

    application live {
        live on;
        gop_cache on; #打开GOP缓存,减少首屏等待时间
    }

    application hls {
        live on;
        hls on;
        hls_path /tmp/hls;
    }

    application dash {
        live on;
        dash on;
        dash_path /tmp/dash;
    }
}

} ` 老大帮我检查下

看看你 /tmp/hls /tmp/dash 文件夹权限