RTMP#

RTMP 模块提供了以 HLS 和 MPEG-DASH 格式进行流媒体传输的能力,适用于希望使用基于 HTTP 协议的简化解决方案的用户。流以 MPEG-TS 格式通过 HTTP 发布。

加载模块#

main{} 上下文中加载模块:

load_module modules/ngx_rtmp_module.so;

配置示例#

http {
    server {
        listen 443 ssl;
        server_name example.com;

        ssl_certificate /var/ssl/example.com.pem;
        ssl_certificate_key /var/ssl/example.com.private;

        location /keys {
            root /tmp;
        }
    }

    server {
        listen 80;
        server_name example.com;

        location /hls {
            root /tmp;
        }
    }
}

rtmp {
    server {
        listen 1935;

        hls on;
        hls_path /tmp/hls;
        hls_keys on;
        hls_key_path /tmp/keys;
        hls_key_url https://example.com/keys/;
        hls_fragments_per_key 2;
    }
}

附加信息#

详细文档和源代码可在以下地址获取: arut/nginx-rtmp-module