Streaming FFmpeg over TCP - ffmpeg

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

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

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.

Related

ffmpeg to nginx rtmp on windows got I/O error

using https://github.com/illuspas/nginx-rtmp-win32
windows server 2018
no touch to conf, just illuspas original, run nginx.exe as admin
firewall disabled
no antivirus
service started as a charm, no error in nginx log
run following cmdline as admin
ffmpeg -re -i "rtsp://111.10.31.131:554/pag://192.168
.1.5:7302:001110:0:MAIN:TCP?cnid=2&pnid=1" -f flv -s 640x480 "rtmp://localhost:1
935/live/abc" -loglevel debug
i got this:
see this pic: https://i.stack.imgur.com/3RpNY.jpg
I want to put the rtsp source to a rtmp channel, why im getting this rtsp://***** I/O error? what does that mean? any idea that i could get this rtmp stream?
any input would be appreciated!
I had the same problem. I had to give my rtmp sink rights to write at the location (i somehow lost it)

Recording pulse audio as CAP_SYS_ADMIN with ffmpeg

As my normal user, this works:
ffmpeg -f pulse -i default -acodec aac foo.aac
but run with sudo is fails with:
default: No such process
How can I run ffmpeg as a privileged user (CAP_SYS_ADMIN), since I am keen to use the kmsgrab option and still get access to sound in order to record it too?
There are two steps to connecting to the Pulse Audio server:
Server path. By default, the PulseAudio server makes itself accessible to clients by creating a UNIX socket under $XDG_RUNTIME_DIR. Running commands via sudo will reset the environment, thus making PulseAudio clients unable to find the server to connect to.
Authentication. By default, the PulseAudio server creates an authentication cookie in ~/.pulse-cookie, which clients must relay to the server upon connecting. If $HOME or $PULSE_COOKIE are not set to the cookie's location, clients will be unable to authenticate.
The complete command of thus running ffmpeg via sudo is as follows:
sudo env \
PULSE_COOKIE=$HOME/.pulse-cookie \
PULSE_SERVER=$XDG_RUNTIME_DIR/pulse/native \
ffmpeg -y -f pulse -i default -acodec aac foo.aac
You can probably substitute PULSE_SERVER with the -server ffmpeg device option.

Issue with netcat command in windows

I have installed netcat for windows 8.
At the command prompt I am giving the command nc -lvp 50050.
I am getting a message "listening on [any] 50050 ..."
But I am not able to type in any message. Can any one please help me what could be wrong.
I am actually trying to test spark streaming to test the messages that I am typing in host 50050
Using the command "nc -vvv -l -p 50050" I am able to start the port 50050. From which I could type in something and listen from SparkStreaming.

how to capture network traffic in the pcap file using tcpdump command?

I want to capture network trafic of my application using tcpdump command.
I'm implemented the Websocket client and server, in which server is sending messages to the connected clients continously. So in that scenario I just want to capture this messages in one pcap file.
previously I used this command which is not working properly :
sudo tcpdump -ni eth0 -s0 -w mycap.pcap
Can anyone told me how to capture such type of network traffic using tcpdump command?
Your syntax is correct.
Are you receiving an error, or is your file "mycap.pcap" empty?
If your file is unexpectedly empty, check if you have another interface that is receiving the traffic.
If all else fails, try -i any for the interface.

iperf UDP server start error, bind failed: Operation not permitted

OS : Windows 8,
Tool : Jperf,
internal Tool : iperf
i want to start UDP Server listener.
Command Used:-
iperf -s -u -P 0 -i 1 -p 5001 -l 1470 -f k -t 10
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 64.0 KByte (default)
Error as follows :-
bind failed: Operation not permitted
recvfrom failed: Invalid argument
Comments :-
1) My Windows Firewall is OFF
2) Antivirus is OFF
Any Registory changes required here to access windows UDP ports ?
Any Idea ?
I had the same problem, but only after I installed an altogether different application on the same machine where I had successfully run iperf -s -u previously. When I assigned another port for iperf to use such as 5555 or 6007 the iperf server no longer gave a bind error and presented the stats after the transfer as expected.
I suspect the reason for this is that another program that I installed grabbed the UDP port or range of ports for itself. This would be easy for a program to do if iperf is running in user-mode instead of daemon mode. On the other hand some programs are still particular about running on specific ports, so in case of a conflict you may still have to assign specific port usage.

Resources