Restart ffmpeg on loss of stream

0

I record a rtmps stream with ffmpeg, occasionally the stream drops out for various reasons (isp failure, network problems) Ffmpeg stops and I have to manualy restart it. Is there a way to monitor for stream loss and restart ffmpeg? Maybe a script? I use Linux. I have tried timout stimout but they do not work.

Here is my ffmpeg command that I enter in terminal

ffmpeg -i rtmps://(url) -r 25 \
-vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: text='%{localtime}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: fontsize=24: box=1: boxcolor=0x00000000@1" \
-f segment -strftime 1 -segment_time 1800 \
-segment_format mkv /media/joe/disk/a/%m_%d_%Y-%H_%M_%S.mkv 
ffmpeg
video-capture
asked on Stack Overflow Oct 21, 2018 by JoeN • edited Oct 21, 2018 by Andrey Moiseev

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0