Nginx-RTMP-Win32 安装与使用指南

Nginx-RTMP-Win32 安装与使用指南

nginx-rtmp-win32Nginx-rtmp-module Windows builds. 项目地址:https://gitcode.com/gh_mirrors/ng/nginx-rtmp-win32

1. 项目目录结构及介绍

Nginx-RTMP-Win32 是一个适用于Windows系统的Nginx与RTMP模块的集成,其基本目录结构如下:

nginx-rtmp-win32/
├── nginx-<version>          # Nginx服务器的主要目录
│   ├── conf                 # 配置文件目录
│   │   └── nginx.conf       # 主配置文件
│   ├── html                 # 默认网页根目录
│   └── logs                 # 日志文件目录
└── nginx-rtmp-module        # RTMP模块源代码
    ├── README.md           # 模块说明文档
    └── ...                  # 其他相关文件
  • nginx-<version>:包含了Nginx服务器的所有文件。
  • conf:存放Nginx的各种配置文件。
  • nginx.conf:Nginx服务器的主要配置文件。
  • html:默认情况下,Nginx会将这个目录作为Web服务器的根目录,存放静态HTML页面。
  • logs:存放Nginx的日志文件。

2. 项目的启动文件介绍

主要启动文件位于 nginx-<version> 目录下,包括:

  • nginx.exe: Nginx服务的主进程文件,用于启动、停止和重新加载Nginx配置。

    • 启动:在命令行中执行 nginx.exe 即可启动Nginx服务器。
    • 停止:使用 nginx.exe -s quit 命令优雅地关闭Nginx(等待所有已连接的客户端完成请求后再退出)。
    • 重新加载配置:使用 nginx.exe -s reload 命令来立即更新配置文件而无需重启服务。

3. 项目的配置文件介绍

nginx.conf

nginx.conf 是Nginx服务器的全局配置文件,通常位于 nginx-<version>/conf 目录下。以下是一份基本配置示例,展示了如何添加RTMP模块支持:

worker_processes  1;

events {
    worker_connections  1024;
}

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

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

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

        # RTMP configuration block
        rtmp {
            server {
                listen 1935; # RTMP port
                chunk_size 4096;
                
                application live {
                    allow publish all;
                    deny publish none;
                    on_publish http://localhost/path/to/on_publish_handler.php; # 可选的on_publish回调处理程序
                    record off; # 是否记录流到磁盘
                    exec_record_done /path/to/script.sh $name; # 可选的脚本在流记录完成后运行
                }
                
                application hls {
                    playlist_length 5m;
                    fragment 10s;
                    hls on;
                    hls_path /tmp/hls;
                    hls_playlist_length 60s;
                }
            }
        }
    }
}

在这个配置中:

  • listen 1935:指定RTMP服务器监听的端口。
  • application liveapplication hls 分别定义了两个应用,一个是用于直播(live),另一个是用于HLS(hls)点播。
  • allow publish all;deny publish none; 控制谁可以发布流。
  • on_publishexec_record_done 分别定义了流发布时和流录制完成后的回调处理器。

请注意,根据实际需求,您可能需要调整这些配置参数以满足您的特定场景。在修改配置后,记得用 nginx.exe -s reload 命令重新加载配置。


以上就是关于Nginx-RTMP-Win32的基本安装和使用指南,祝您在构建流媒体服务的过程中一切顺利!

nginx-rtmp-win32Nginx-rtmp-module Windows builds. 项目地址:https://gitcode.com/gh_mirrors/ng/nginx-rtmp-win32

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汪宾其

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值