fix: Switch to W64 for night long recording

This commit is contained in:
Samuel Ortion 2024-01-04 17:42:40 +01:00
parent 5cf0864b75
commit bf665bbb33
4 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,6 @@
# NBMrec configuration file # NBMrec configuration file
START_TIME=22:00 START_TIME=17:00
END_TIME=06:00 END_TIME=08:00
RECORD_DIR=/mnt/DATA/media/records RECORD_DIR=/mnt/DATA/media/records
PREFIX=nbmrec PREFIX=nbmrec
VERBOSE=false VERBOSE=false

View File

@ -19,8 +19,8 @@ install()
sudo sed -i "s/<USER>/$USER/g" /etc/systemd/system/nbmrec.service sudo sed -i "s/<USER>/$USER/g" /etc/systemd/system/nbmrec.service
sudo sed -i "s/<start_time>/$START_TIME/g" /etc/systemd/system/nbmrec.timer sudo sed -i "s/<start_time>/$START_TIME/g" /etc/systemd/system/nbmrec.timer
sudo systemctl daemon-reload # sudo systemctl daemon-reload
sudo systemctl enable --now nbmrec.timer # sudo systemctl enable --now nbmrec.timer
} }
uninstall() uninstall()

2
run.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/bash
screen -dmS nbmrec /usr/local/bin/nbmrec.sh

View File

@ -11,12 +11,14 @@ RECORD_FILENAME="${PREFIX}_$(date +"%Y%m%d_%H%M%S").wav"
RECORD_FILEPATH="${RECORD_DIR}/${RECORD_DATE}/${RECORD_FILENAME}"  RECORD_FILEPATH="${RECORD_DIR}/${RECORD_DATE}/${RECORD_FILENAME}" 
START_TIME="22:00" START_TIME="22:00"
END_TIME="06:00" END_TIME="06:00"
RECORD_DURATION=$(( $(date -d "$END_TIME + 1 day" "+%s") - $(date -d "$START_TIME" "+%s") )) START_TIMESTAMP=$(date -d "$START_TIME" "+%s")
END_TIMESTAMP=$(date -d "$END_TIME + 1 day" "+%s")
RECORD_DURATION=$(( $START_TIMESTAMP - $END_TIMESTAMP ))
VERBOSE=false VERBOSE=false
# Load conf file if any # Load conf file if any
if [ -f /usr/local/etc/nbmrec/nbmrec.conf ]; then if [ -f /usr/local/etc/nbmrec/nbmrec.conf ]; then
source /usr/local/etc/nbmrec.conf source /usr/local/etc/nbmrec/nbmrec.conf
fi fi
RECORD_DURATION=$(( $(date -d "$END_TIME + 1 day" "+%s") - $(date -d "$START_TIME" "+%s") )) RECORD_DURATION=$(( $(date -d "$END_TIME + 1 day" "+%s") - $(date -d "$START_TIME" "+%s") ))
@ -55,26 +57,29 @@ while getopts ":hd:f:" opt; do
esac esac
done done
main() { main() {
# Create output folder # Create output folder
if $VERBOSE if $VERBOSE
then then
echo "Creating record output folder" echo "Creating record output folder"
fi fi
mkdir -p "$RECORD_DIR/$RECORD_DATE/" mkdir -p "$RECORD_DIR/$RECORD_DATE/"
# Perform recording # Perform recording
if $VERBOSE if $VERBOSE
then then
echo "Recording $RECORD_FILENAME" echo "Recording $RECORD_FILENAME"
fi fi
rec -b 16 -r 48000 -c 1 -t wav $RECORD_FILEPATH trim 0 $RECORD_DURATION
while [[ $(date "+%s") -le $END_TIMESTAMP ]]; do
rec -b 16 -r 48000 -c 1 -t w64 $RECORD_FILEPATH trim 0 $RECORD_DURATION > /tmp/nbmrec-rec.log
done
if $VERBOSE if $VERBOSE
then then
echo "Done" echo "Done"
fi fi
} }
main main
exit 0 exit 0