small tweaks to birdnet_anaysis.sh

This commit is contained in:
mcguirepr89
2022-02-05 15:06:58 -05:00
parent af7b76895a
commit 2781c32f76
+7 -7
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Runs BirdNET-Lite
#set -x
set -x
source /etc/birdnet/birdnet.conf
# Document this run's birdnet.conf settings
# Make a temporary file to compare the current birdnet.conf with
@@ -78,7 +78,7 @@ move_analyzed() {
# Uses one argument:
# - {DIRECTORY}
run_analysis() {
sleep .5
sleep .5
echo "Starting run_analysis() for ${1:19}"
@@ -101,25 +101,25 @@ run_analysis() {
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=15
[ ${RECORDING_LENGTH} == "60" ] && RECORDING_LENGTH=01:00
FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)"
[ -z $FILE_LENGTH ] && sleep 2 && continue
[ -z $FILE_LENGTH ] && sleep 1 && continue
echo "RECORDING_LENGTH set to ${RECORDING_LENGTH}"
a=1
a=0
if [ "${RECORDING_LENGTH}" == "01:00" ];then
until [ "$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" == "${RECORDING_LENGTH}" ];do
sleep 1
[ $a -ge 60 ] && sudo rm -f ${1}/${i} && break
[ $a -ge 60 ] && rm -f ${1}/${i} && break
a=$((a+1))
done
elif [ "${RECORDING_LENGTH}" -lt 10 ];then
until [ "$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" == "00:0${RECORDING_LENGTH}" ];do
sleep 1
[ $a -ge ${RECORDING_LENGTH} ] && sudo rm -f ${1}/${i} && break
[ $a -ge ${RECORDING_LENGTH} ] && rm -f ${1}/${i} && break
a=$((a+1))
done
else
until [ "$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)" == "00:${RECORDING_LENGTH}" ];do
sleep 1
[ $a -ge ${RECORDING_LENGTH} ] && sudo rm -f ${1}/${i} && break
[ $a -ge ${RECORDING_LENGTH} ] && rm -f ${1}/${i} && break
a=$((a+1))
done
fi