一. 安装 Nginx 服务器
- 下载带 rtmp 模块的 nginx 版本(选择后缀为 Gryphon 的版本);
二. 安装 nginx-rtmp-module
- 下载 rtmp 模块;
- 将文件下载至 Nginx 解压后的目录下;
- 解压后更将文件名从 nginx-rtmp-module-master 更改为 nginx-rtmp-module;
三. 编辑配置文件conf\nginx-win.conf
- 在此文件最后添加如下:
rtmp {
server {
listen 1935;
chunk_size 4000;
application live {
live on;
}
}
}
四. 启动Nginx服务
- 进入nginx-XXXX-Gryphon目录,输入命令启动Nginx rtmp服务:
nginx.exe -c conf\nginx-win.conf
- 此步骤若出现端口80占用的错误,则进入 nginx-win.conf 中进行如下修改:(将80端口改为81端口或其他合法端口)

六. RTMP 推流拉流测试
- FFmpeg本地视频推流测试:(其中 -i 后面的参数为要推流的视频路径,最后的参数为 rtmp 流的地址)
ffmpeg -re -i ./test.mp4 -vcodec copy -acodec copy -f flv "rtmp://127.0.0.1:1935/live/test"
- ffplay拉流测试:(参数填写为 rtmp 的推流地址)
ffplay rtmp:
七. Nginx常用命令
- 前提条件:使用命令前需要将 conf 文件夹中的 nginx-win.conf 复制一份,并重命名为 nginx.conf
- 启动 Nginx
start nginx
- 关闭 Nginx
nginx -s stop
- 优雅的关闭(完整有序的停止 Nginx,并保存相关信息)
nginx -s quit
- 重新加载配置
nginx -s reload
八. Linux 下配置 Nginx