[FFmpeg-user] ffmpeg not stopping when the OUTPUT connection goes down

Jim Carroll jfcarroll at yahoo.com
Thu Feb 21 17:29:11 EET 2019

Hello  all,

I've scowered for an answer to this but I can't seem to find anything. I'm using ffmpeg to move a camera stream to a server as follows:

ffmpeg -i rtsp://[rtsp source ip]:554 -acodec copy -vcodec copy -f flv rtmp://[rtmp destination ip]:1935/live/myfeed

This works great. I have it running with a watchdog so when a connection to the source goes down and the process exits, it restarts it correctly. When I look at "netstat -an" when it's working I see:

tcp        0      0        [rtsp source ip]:554        ESTABLISHED
tcp        0      0        [rtmp destination ip]:1935       ESTABLISHED

Occasionally all processing will stop when ffmpeg looses its  OUTPUT connection to the rtmp server. When I tail the output I see nothing happening and the connection rtmp connection is gone from netstat, yet the process is still running.

The documentation has an rtmp timeout but that's only when ffmpeg is running a listener and taking an rtmp stream as input.

Am I missing something? I'd rather not have the watchdog periodically run netstat to see if the connection is live and then kill the ffmpeg process. That seems like the wrong approach. Shouldn't ffmpeg exit with an error code if the output rtmp connection goes down?


More information about the ffmpeg-user mailing list