<p>You can use FFmpeg as an RTMP server as following
<code>ffmpeg -f flv -listen 1 -i rtmp://localhost:1935/live/app -c copy rtsp://YOUR_RTSP_HOST</code></p>

<p>Notes:</p>

<ul>
<li><code>-listen 1</code> makes FFmpeg act as a RTMP server when used with RTMP protocol</li>
<li>Use <code>rtmp://localhost:1935/live/app</code> as the RTMP server url on the source </li>
<li>You can set any playpath <code>rtmp://localhost:1935/any/thing</code> and any port</li>
<li>The main advantage with this way is simplicity, the disadvantage is server stops if source stopped or had encoding errors</li>
<li>The other option is to use nginx with <a href="https://github.com/arut/nginx-rtmp-module" rel="noreferrer">nginx-rtmp-module</a></li>
</ul>

CC BY-SA 4.0
2019-03-18T00:15:55.967Z
Perfect, thanks a ton. If I'd like to use an application such as VLC to receive the stream from the server, can ffmpeg listen for a connection and output to local port 1935 as well?
WarmTaunTaun
CC BY-SA 4.0
2019-03-18T13:05:18.983Z
Yes, `ffmpeg -f flv -listen 1 -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app`, just set different ports for input and output
Marware
CC BY-SA 4.0
2019-03-18T18:43:37.377Z
Thanks again, this is exactly what I need. While testing it I've tried just about every combination of /live/app on the Teradek Cube and various iOS RTMP streaming video apps to test this, and ffmpeg is unresponsive while monaserver works. Is 'app' the key, and does live have to be included in the client's url?
WarmTaunTaun
CC BY-SA 4.0
2019-03-18T19:46:42.880Z
Would elaborate how you set the RTMP urls in Cube, iOS apps and Monaserver? do you open required ports? 
You can set any playpath /any/thing
Marware
CC BY-SA 4.0
2019-03-18T19:47:24.783Z
Also FFmpeg Input server starts when it receives stream, and the output starts when it receives a request
Marware
CC BY-SA 4.0
2019-03-18T20:00:03.853Z
On the iOS streaming apps I only entered rtmp://serveraddress (with open ports 1935 and 554) and monaserver connected. In VLC I then just connected to the same address. Some apps required a stream key field, which was live by default. When ffmpeg is listening, no matter what url is entered as an input it's unresponsive.
WarmTaunTaun
CC BY-SA 4.0
2022-09-01T06:01:30.330Z
@Marware, is the double `-listen 1` in your second comment correct? The second one is being applied to the output URL, so I think it doesn't make sense to start a listening server... Maybe is it just duplicated by copy&pasting the command?
Piranna
CC BY-SA 4.0
2022-09-01T19:20:20.043Z
@Piranna Correct, It should be `ffmpeg -f flv -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app`
Marware
CC BY-SA 4.0
2022-09-03T08:23:34.067Z
Can you be able to update your comment with the fixup?
Piranna
CC BY-SA 4.0
2022-09-04T20:33:10.860Z
Also, how is that you are applying `-listen 1` to the second one instead of the former one?
Piranna
CC BY-SA 4.0
2019-03-18T00:09:04.450Z
2019-03-18T13:04:11.030Z
2019-03-18T13:04:11.030Z
Marware
<p>I'd like to use a Teradek Cube connected to a broadcast camera to push to a server running ffmpeg with an open RTMP port, and have ffmpeg re-stream that feed to a decoder using RTMP or RTSP.</p>

<p>Monaserver does this, but I need to duplicate this functionality using ffmpeg. I would use the Cube as a server, except it could be broadcasting anywhere so opening ports at every location the camera goes to is not an option. Our decoder is a Teradek Slice. Any other suggestions about how to do this would be greatly appreciated.</p>

<p>Thank you!</p>

<ffmpeg><streaming><rtmp>
RTMP server using ffmpeg
WarmTaunTaun
# RTMP server using ffmpeg

(Asked by: username_0 on 2019-03-17)

I'd like to use a Teradek Cube connected to a broadcast camera to push to a server running ffmpeg with an open RTMP port, and have ffmpeg re-stream that feed to a decoder using RTMP or RTSP.

Monaserver does this, but I need to duplicate this functionality using ffmpeg. I would use the Cube as a server, except it could be broadcasting anywhere so opening ports at every location the camera goes to is not an option. Our decoder is a Teradek Slice. Any other suggestions about how to do this would be greatly appreciated.

Thank you!

**Tags:** ffmpeg, streaming, rtmp


---

## 1 answers

### Answer by username_1 on 2019-03-18. Score: 20 | Accepted answer

You can use FFmpeg as an RTMP server as following
`ffmpeg -f flv -listen 1 -i rtmp://localhost:1935/live/app -c copy rtsp://YOUR_RTSP_HOST`

Notes:

* `-listen 1` makes FFmpeg act as a RTMP server when used with RTMP protocol
* Use `rtmp://localhost:1935/live/app` as the RTMP server url on the source
* You can set any playpath `rtmp://localhost:1935/any/thing` and any port
* The main advantage with this way is simplicity, the disadvantage is server stops if source stopped or had encoding errors
* The other option is to use nginx with [nginx-rtmp-module](https://github.com/arut/nginx-rtmp-module)

> **Comments:**
> **username_0**: Perfect, thanks a ton. If I'd like to use an application such as VLC to receive the stream from the server, can ffmpeg listen for a connection and output to local port 1935 as well?  
> **username_1**: Yes, `ffmpeg -f flv -listen 1 -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app`, just set different ports for input and output  
> **username_0**: Thanks again, this is exactly what I need. While testing it I've tried just about every combination of /live/app on the Teradek Cube and various iOS RTMP streaming video apps to test this, and ffmpeg is unresponsive while monaserver works. Is 'app' the key, and does live have to be included in the client's url?  
> **username_1**: Would elaborate how you set the RTMP urls in Cube, iOS apps and Monaserver? do you open required ports?  You can set any playpath /any/thing  
> **username_1**: Also FFmpeg Input server starts when it receives stream, and the output starts when it receives a request  
> **username_0**: On the iOS streaming apps I only entered rtmp://serveraddress (with open ports 1935 and 554) and monaserver connected. In VLC I then just connected to the same address. Some apps required a stream key field, which was live by default. When ffmpeg is listening, no matter what url is entered as an input it's unresponsive.  
> **username_2**: @username_1, is the double `-listen 1` in your second comment correct? The second one is being applied to the output URL, so I think it doesn't make sense to start a listening server... Maybe is it just duplicated by copy&pasting the command?  
> **username_1**: @username_2 Correct, It should be `ffmpeg -f flv -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app`  
> **username_2**: Can you be able to update your comment with the fixup?  
> **username_2**: Also, how is that you are applying `-listen 1` to the second one instead of the former one?  

---

