ffmpeg monitor and restart stream when it hung or stall
while true
ffmpeg -re -i https://roundrobin3.videostreamingwowza.com/visdeurbel2/visdeurbel2.stream/playlist.m3u8 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "rtmp://a.rtmp.youtube.com/live2/abcd-efgh-ijkl" > youtube.log
sleep 5
end#!/bin/sh
#sleep 10
while true
do
frameA=$(grep "videostreamingwowza" youtube.log | tail -n1 | sed -n 's/.*\(roundrobin3.videostreamingwowza.com.*\.ts.*\)/\1/p')
echo "A: $frameA"
sleep 30
frameB=$(grep "videostreamingwowza" youtube.log | tail -n1 | sed -n 's/.*\(roundrobin3.videostreamingwowza.com.*\.ts.*\)/\1/p')
echo "B: $frameB"
if [ "$frameA" = "$frameB" ]
then
echo "Stream has hung"
printf "%s - Stream has hung\n" "$(date)" >> stream.log
pkill ffmpeg
echo "killed ffmpeg..."
fi
sleep 2
doneLast updated