From 9dbedd7799d1a841bc4288b640c2b845738c9f3a Mon Sep 17 00:00:00 2001 From: Patrick McGuire Date: Sun, 3 Oct 2021 12:53:46 -0400 Subject: [PATCH] slowing down the analysis service to prevent unneeded restarts --- scripts/birdnet_analysis.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/birdnet_analysis.sh b/scripts/birdnet_analysis.sh index a4c7ccb..51e7146 100755 --- a/scripts/birdnet_analysis.sh +++ b/scripts/birdnet_analysis.sh @@ -74,20 +74,25 @@ run_analysis() { WEEK="$(echo "${WEEK_OF_YEAR} + 4" |bc -l)" fi - #WEEK=$(date +"%U") cd ${HOME}/BirdNET-Lite || exit 1 for i in "${files[@]}";do - FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 \ - | awk -F. '/Duration/ {print $1}' \ - | cut -d':' -f3-4)" [ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=12 [ ${RECORDING_LENGTH} == "60" ] && RECORDING_LENGTH=01:00 + FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" +#################################################################### working on this +set -x +[ -z $FILE_LENGTH ] && sleep "$(echo "${RECORDING_LENGTH}/3"|bc -l)" && continue if [ ${RECORDING_LENGTH} == "01:00" ];then - [ "${FILE_LENGTH}" == "${RECORDING_LENGTH}" ] || continue + until [ "$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" == "${RECORDING_LENGTH}" ];do + sleep 1 + done else - [ "${FILE_LENGTH}" == "00:${RECORDING_LENGTH}" ] || continue + until [ "$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" == "00:${RECORDING_LENGTH}" ];do + sleep 1 + done fi +#################################################################### working on this if [ -f ${1}/${i} ] && [ ! -f ${CUSTOM_LIST} ];then set -x