最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to set ffmpeg reconnect or quit when rtsp stream connection breaks - Stack Overflow

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论