run_ffmpeg() {
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" &
pid=$!
while true
do
sleep 1
if ! ps -p "${pid}" 1>/dev/null
then
run_ffmpeg "$@"
echo $?
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 &