#!/bin/sh
video="Stream #0:0: Video"
audio="Stream #0:1: Audio"
run_ffmpeg() {
while ! ffmpeg -y -nostdin -loglevel quiet -hide_banner -fflags +genpts -i "$1" -strict -2 -dn -deinterlace -vcodec h264 -acodec aac -preset superfast -threads 0 -scodec copy -hls_flags delete_segments -hls_time 10 -hls_list_size 6 "$2"
do
sleep 1
ffprobe http://xx.xx.xx.xx/ch001.m3u8 > test.txt 2>&1
if grep -Fq "$video" test.txt
then
echo "Video is up"
else
echo "Stream is Down"
fi
done
}
run_ffmpeg http://xx.xx.xx.xx:9110/ch001/mpegts /var/www/html/ch001.m3u8 &
run_ffmpeg http://xx.xx.xx.xx:9110/ch002/mpegts /var/www/html/ch002.m3u8 &
run_ffmpeg http://xx.xx.xx.xx:9110/ch003/mpegts /var/www/html/ch003.m3u8 &