vlambda博客
学习文章列表

nginx的rtmp配置文件参考

rtmp {
    server {
        listen 1935; #监听端口 rtmp协议默认端口是1935
        chunk_size 4000;
        # RTMP 直播流配置
        application live {
            live on;
            hls on;                 # HLS 输入流必须是 H264/AAC 格式
            hls_path /tmp/hls/live; # 请先创建目录 /tmp/hls
            hls_fragment 1s;        # hls 切片
            hls_playlist_length 4s; # hls 播放列表长度

            record off;             # 录制关闭
      }
            # 如果你想重新转码视频流请使用 'exec'
        }
    }

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

    # 设置超时限制
    keepalive_timeout 165;

    server {
        listen 88;      # HTTP IPv4
     #  listen [::]:80; # HTTP IPv6
       
        # 域名 (建议使用可选)
        # server_name example.com www.example.com;
       
        location /live {
            # 允许跨域 使用IP访问请忽略
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

            # 允许跨域预检请求
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }

            # 指定提供的文件类型 (.m3u8)
                types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t;




需要完整配置与我联系。