在 Nginx 中配置 RTMP 的步骤有:安装 RTMP 模块编辑 Nginx 配置文件,添加 RTMP 配置创建用于推送和拉取流的 RTMP 流源重启 Nginx使用 VLC 播放器验证配置

如何在 Nginx 中配置 RTMP
为了在 Nginx 中配置 RTMP,请按照以下步骤操作:
1. 安装 RTMP 模块
<code class="bash">apt-get install nginx-module-rtmp</code>
2. 配置 Nginx
在 Nginx 配置文件 /etc/nginx/nginx.conf 中,添加以下内容:
<code class="conf">rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
push "push.stream";
pull "live.stream";
live on;
}
}
}</code>3. 创建 RTMP 流源
创建两个流源,一个用于推送流,一个用于拉取流:
<code class="bash"># 推送流源 ffmpeg -re -i input.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/live/push.stream # 拉取流源 ffmpeg -i rtmp://localhost:1935/live/live.stream output.mp4</code>
4. 重启 Nginx
<code class="bash">systemctl restart nginx</code>
5. 验证配置
您可以使用 VLC 媒体播放器连接到 RTMP 流源以验证配置:
rtmp://localhost:1935/live/push.stream
rtmp://localhost:1935/live/live.stream
以上就是nginx如何配置rtmp的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号