-err_detect aggressive
и -progress /tmp/ffmpeg.log
, остальное можете переделывать под себя. nginx и все остальное - по вкусу. #!/bin/bash
touch /tmp/ffmpeg.log
ffmpeg -shortest -re -y -err_detect aggressive -i \
rtmp://127.0.0.1/movies/my.stream timeout=10 -codec copy \
-map 0 -bsf:v h264_mp4toannexb,dump_extra -f segment \
-segment_time 60 -progress /tmp/ffmpeg.log /video/my.stream#%09d.ts &
pid=$!
while true
do
# you'll might have to change "invalid"
# for whatever is being put into the progress log
# just look at /tmp/ffmpeg.log to figure out what
# grep should try to find
error=$(grep -n "invalid" /tmp/ffmpeg.log)
# is the length of the error more than 0 / did grep find it???
if (( ${#error} > 0 ))
then
kill -9 $pid
ffmpeg -shortest -re -y -err_detect aggressive -i \
rtmp://127.0.0.1/movies/my.stream timeout=10 -codec copy \
-map 0 -bsf:v h264_mp4toannexb,dump_extra -f segment \
-segment_time 60 -progress /tmp/ffmpeg.log /video/my.stream#%09d.ts &
pid=$!
else
usleep 100
fi
done
exit 0
Ответ должен выглядеть как "на смартфоне, смартфон - в помещении", например.
OpenStreetMap тут, к слову, вообще не при чём.