Search code examples
nginxffmpegubuntu-18.04rtmp

Serving rtmp on port 1935


I've been trying to get ffmpeg to stream in rtmp but connection to port 1935 is always refused. I really don't know what else I can do to allow this connection.

Here is what specs I'm running.

  • Ubuntu 18.04 (tried with 19.04) however same issue - here is why I think I've made a mistake
  • No Nginx installation at the moment
  • 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)"

This is the script I run:

ffmpeg -i "test.mp4" -c:v copy -c:a copy -f flv "rtmp://127.0.0.1/stream/test"

Error I get is:

[tcp @ 0x55ff05ab8ce0] Connection to tcp://127.0.0.1:1935 failed: Connection refused

I've done some research and been across many posts about ffserver.conf and I have made those changes but still no luck. Here is my config file. I also have ran ffserver once using this config.




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>

Here is my ufw status:

--                         ------      ----
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)

but still nothing, I've also opened ports in iptables but no luck. Here is how this is done:

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

and still nothing, every time I run ffmpeg I get connection refused. I have previously installed nginx just to test but no luck.

What am I doing wrong here? Isn't this port suppose to be open now?

Thanks


Solution

  • I figured it out, I was using Nginx RTMP module - Nginx RTMP for some reason doesn't work well on Ubuntu but fine with Alpine 3.8 - As soon as I started a nginx rtmp docker container and exposed 1935 and 80 everything started working fine. Listen learnt, never install nginx rtmp module on ubuntu.