在端口 1935 上提供 rtmp
Serving rtmp on port 1935
我一直在尝试让 ffmpeg 在 rtmp 中流式传输,但始终拒绝连接到端口 1935。我真的不知道我还能做些什么来允许这种连接。
这是我运行宁的规格。
- Ubuntu 18.04(尝试使用 19.04)但是同样的问题 - 这就是为什么我认为我犯了一个错误
- 目前没有安装 Nginx
- FFMPEG "ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers built with 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 模块。
@JJ-the-Second,我一直在 ubuntu 上本地使用 nginx rtmp 模块,它工作得很好。但是我没有将流发送到 127.0.0.1
,而是将它发送到 localhost
或 0.0.0.0
我一直在尝试让 ffmpeg 在 rtmp 中流式传输,但始终拒绝连接到端口 1935。我真的不知道我还能做些什么来允许这种连接。
这是我运行宁的规格。
- Ubuntu 18.04(尝试使用 19.04)但是同样的问题 - 这就是为什么我认为我犯了一个错误
- 目前没有安装 Nginx
- FFMPEG "ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers built with 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 模块。
@JJ-the-Second,我一直在 ubuntu 上本地使用 nginx rtmp 模块,它工作得很好。但是我没有将流发送到 127.0.0.1
,而是将它发送到 localhost
或 0.0.0.0