From be800cd51a1967b0b6069b1b8e6170627d914ba2 Mon Sep 17 00:00:00 2001 From: frederik Date: Sat, 23 Apr 2022 18:37:55 +0200 Subject: [PATCH] avoid using ffmpeg: just wait until the file is closed --- scripts/birdnet_analysis.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/birdnet_analysis.sh b/scripts/birdnet_analysis.sh index d456a0e..a031245 100755 --- a/scripts/birdnet_analysis.sh +++ b/scripts/birdnet_analysis.sh @@ -95,15 +95,8 @@ run_analysis() { echo "${1}/${i}" > $HOME/BirdNET-Pi/analyzing_now.txt [ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=15 echo "RECORDING_LENGTH set to ${RECORDING_LENGTH}" - if [ "${RECORDING_LENGTH}" == 60 ];then - RECORDING_LENGTH_MATCH="01:00" - elif [ "${RECORDING_LENGTH}" -lt 10 ];then - RECORDING_LENGTH_MATCH="00:0${RECORDING_LENGTH}" - else - RECORDING_LENGTH_MATCH="00:${RECORDING_LENGTH}" - fi a=0 - until [ "$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" == "${RECORDING_LENGTH_MATCH}" ];do + until [ -z "$(lsof -t ${1}/${i})" ];do sleep 1 [ $a -ge ${RECORDING_LENGTH} ] && rm -f ${1}/${i} && break a=$((a+1))