[FFmpeg-user] How to restart a fmmpeg frozen stream
Sergio A S de Aguiar
ssaguiar2 at hotmail.com
Wed Apr 10 15:37:09 EEST 2019
I am working in a transcoder to capture a camera stream and transcode it to send a multibitrate encrypted stream.
So far, so good.
The problem is that sometime the stream crashes and keep sending black frames (or the some frozen frame continuously), so the ffmpeg is running but there is no image (just the black stream or the frozen frame, as I stated).
The imput is working.
I think this can be caused by some momentanous problem with the input stream wich makes ffmpeg loose the sync.
I want to detectt when the output frames doesn't change and restart the bash script wich is using ffmpeg.
At this time I am using a compex filter to detect when there is no change of the frames for the last 20 seconds (600 frames).
This is the script:
echo "Starting cam1frozen" >> /mnt/sdd/html/frozen.log
/mnt/sdd/html/./CAM1FROZEN -y -hide_banner -loglevel warning -threads 0 \
-i "rtsp://192.168.1.100:554/live/ch00_0" \
-filter_complex "select='not(mod(n,600))',select='lt(scene\,0.06)',drawbox=y=ih-h:color=black at 0.4:width=iw:height=48:t=fill,drawtext=fontfile=/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf:fontsize=40:fontcolor=0xAAFFAA:text='No Movement':x=10:y=h-th-10" \
-vsync vfr /mnt/sdd/html/hls/live/CAM1/frozen/frozen_CAM1_%06d.jpg \
>> /mnt/sdd/html/frozen.log 2>&1 &
Obs: The CAM1FROZEN is ffmpeg renamed so it's easy to find usinf ps.
It is generating the jpg files, as expected.
Now the question: How can use this to execute an external bash script wich will kill and restart the capture script?
Thanks for your help
More information about the ffmpeg-user