nginx - 在端口 1935 上提供 rtmp
问题描述
我一直在尝试让 ffmpeg 在 rtmp 中流式传输,但始终拒绝连接到端口 1935。我真的不知道我还能做些什么来允许这种连接。
这是我正在运行的规格。
- Ubuntu 18.04(尝试使用 19.04)但是同样的问题 - 这就是为什么我认为我犯了一个错误
- 目前没有安装 Nginx
- FFMPEG“ffmpeg 版本 3.4.6-0ubuntu0.18.04.1 版权所有 (c) 2000-2019 FFmpeg 开发人员使用 gcc 7 (Ubuntu 7.3.0-16ubuntu3) 构建”
这是我运行的脚本:
ffmpeg -i "test.mp4" -c:v copy -c:a copy -f flv "rtmp://127.0.0.1/stream/test"
我得到的错误是:
[tcp @ 0x55ff05ab8ce0] Connection to tcp://127.0.0.1:1935 failed: Connection refused
我已经进行了一些研究并浏览了许多有关 ffserver.conf 的帖子,并且我已经进行了这些更改,但仍然没有运气。这是我的配置文件。我也曾经使用这个配置运行过 ffserver 。
HTTPPort 8090
HTTPBindAddress 127.0.0.1
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 200K
# Only allow connections from localhost to the feed.
ACL allow 127.0.0.1
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Feed>
<Stream test1.mpg>
# coming from live feed 'feed1'
Feed feed1.ffm
Format mpeg
AudioBitRate 32
# Number of audio channels: 1 = mono, 2 = stereo
AudioChannels 2
AudioSampleRate 44100
# Bitrate for the video stream
VideoBitRate 64
# Ratecontrol buffer size
VideoBufferSize 40
# Number of frames per second
VideoFrameRate 3
</Stream>
<Stream test.asf>
Feed feed1.ffm
Format asf
VideoFrameRate 15
VideoSize 352x240
VideoBitRate 256
VideoBufferSize 40
VideoGopSize 30
AudioBitRate 64
StartSendOnKey
</Stream>
# Special streams
# Server status
<Stream stat.html>
Format status
ACL allow localhost
ACL allow 127.0.0.1
ACL allow 192.168.0.0 192.168.255.255
#FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico
</Stream>
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>
这是我的ufw状态:
-- ------ ----
22/tcp ALLOW Anywhere
22 ALLOW Anywhere
1935/tcp ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
1935/tcp (v6) ALLOW Anywhere (v6)
但仍然没有,我也在 iptables 中打开了端口,但没有运气。这是如何完成的:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT
and
iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT
仍然一无所获,每次我运行 ffmpeg 我都会被拒绝连接。我之前安装了 nginx 只是为了测试但没有运气。
我在这里做错了什么?这个端口现在不是应该开放的吗?
谢谢
解决方案
我想通了,我使用的是 Nginx RTMP 模块 - Nginx RTMP 出于某种原因在 Ubuntu 上运行不佳,但在 Alpine 3.8 上运行良好 - 一旦我启动 nginx rtmp docker 容器并暴露 1935 和 80,一切都开始正常工作。听听学习,永远不要在 ubuntu 上安装 nginx rtmp 模块。
推荐阅读
- ansible - 在 localhost 中运行 Ansible 任务
- python - 错误:类 uri 'eventlet' 无效或未找到
- c# - 如何在 XAML 中添加 TreeView.Resources 的条件模板?
- asp.net-core - NETCORE 配置根内存泄漏
- python - 使用 django 将网站应用程序部署到 heroku 时显示 Apliction 错误
- apache - ECS 日志记录(awslogs 驱动程序)仅将 apache 服务器启动日志记录到 cloudwatch,没有 error.log 和没有 access.log
- c# - 将 Unity 的标准(粗糙度)着色器属性添加到自定义着色器?
- google-contacts-api - 谷歌联系人 REST API 中的查询字段
- java - 显示通用树的节点时,toString 不会显示预期结果
- android - 当应用程序不活动时将接收消息发送到电子邮件