forthrin
forthrin

Reputation: 2777

Streaming FFmpeg over TCP

I'm experimenting with streaming video using the following basic method, which works fine:

$ ffmpeg -re -i INPUT -f mpegts udp://127.0.0.1:2000
$ ffplay udp://127.0.0.1:2000

However, when replacing udp with tcp (see here), ffmpeg says "connection refused".

[tcp @ 0x7f9ddb408880] Connection to tcp://127.0.0.1:2000 failed: Connection refused
tcp://127.0.0.1:2000: Connection refused

How do I fix this?

(All articles I find on the "connection refused" topic relate to FFserver, which is discontinued.)

Using macOS + FFmpeg 4.0.3

Upvotes: 6

Views: 23129

Answers (2)

JustPassingBy
JustPassingBy

Reputation: 51

Did you specify the "listen" option on one side? i.e.
ffmpeg -re -i INPUT -f mpegts tcp://127.0.0.1:2000\?listen

Upvotes: 5

vvk
vvk

Reputation: 21

Connection to tcp://127.0.0.1:2000 failed: Connection refused

This could also appear when there is a process/program already running at that port (in your case, port 2000) and you try to run another program on it or run the same program once more.

You can use,

netstat -tupln

to see if any program is running on that port.

If you want to run any program while a program is already running on that port, you can kill the existing program using,

kill -9 $(lsof -i:<port_number>)

In your case,

kill -9 $(lsof -i:2000)

After killing the program on the port you can try ffmpeg command again.

Upvotes: 2

Related Questions