I use ffmpeg to save rtsp stream from my wi-fi camera. It works fine but when connection dies, I don't get any notice or it doesn't reconnect automatically. Here's my command:
screen -S garage ffmpeg -hide_banner -y -loglevel error -rtsp_transport tcp -use_wallclock_as_timestamps 1 -i rtsp://user:[email protected]:XXX/stream1 -vcodec copy -acodec copy -f segment -reset_timestamps 1 -segment_time 14400 -segment_format mkv -segment_atclocktime 1 -strftime 1 garage%Y%m%dT%H%M%S.mkv
I found this code from this site (if I remember correctly), tinkered a little (added screen -S) and got it working fine. Now I check my stream every morning by looking saved files and are they in realtime. If yes, then I know that stream is working. Needless to say that this is quite cumbersome technique.
So what I need is that the stream reconnects if it fails to connect. This would be best. Second best option would be that it kills screen. Now it just seems do its job even if its not recording anything. I think the connection breaks from time to time because wi-fi is what it is. For that I can't do anything.