From 2f251415ad43a400ad6fb4455c6a89d84bb81c13 Mon Sep 17 00:00:00 2001 From: Anton Schubert Date: Sat, 14 Nov 2020 02:29:07 +0100 Subject: [PATCH] add stable-ffplay script --- scripts/stable-ffplay.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/stable-ffplay.sh diff --git a/scripts/stable-ffplay.sh b/scripts/stable-ffplay.sh new file mode 100755 index 0000000..347e6c6 --- /dev/null +++ b/scripts/stable-ffplay.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# srt-live-transmit wrapper which actually manages to reconnect a failed srt stream +url=$1 +pid=$$ +fifo="/tmp/srt.${pid}" + +trap 'rm "${fifo}"' EXIT + +while true; do + srt-live-transmit -a no "${url}" file://con > ${fifo} & + p1=$! + ffplay -v warning -hide_banner -nostats ${fifo} & + p2=$! + + # check whether we still have 2 running jobs + num_jobs="$(jobs -p | wc -l)" + while [ $num_jobs -ge 2 ]; do + sleep 1 + num_jobs="$(jobs -p | wc -l)" + done + + kill ${p1} ${p2} + sleep 1 +done