First run attempt using this configuration
This commit is contained in:
parent
0a81153e01
commit
4ee9917dc1
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
.venv/
|
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
all: run
|
||||||
|
|
||||||
|
run:
|
||||||
|
./rec.sh
|
||||||
|
|
||||||
|
install:
|
||||||
|
sudo cp ./src/rec.sh /usr/local/bin/rec.sh
|
||||||
|
sudo cp ./conf/nbmrec.service /etc/systemd/system/nbmrec.service
|
||||||
|
sudo cp ./conf/nbmrec.timer /etc/systemd/system/nbmrec.timer
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable nbmrec.timer
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
sudo rm -rf /usr/local/bin/rec.sh
|
||||||
|
sudo rm -rf /etc/systemd/system/nbmrec.service /etc/systemd/system/nbmrec.timer
|
||||||
|
sudo systemctl daemon-reload
|
@ -1,3 +1,9 @@
|
|||||||
# NBMrec
|
# NBMrec
|
||||||
|
|
||||||
Daemon recorder for nocturnal bird migration
|
Daemon recorder for nocturnal bird migration
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
- [audio recording using python](https://realpython.com/playing-and-recording-sound-python/)
|
||||||
|
|
||||||
|
- [audio recording from command line](https://superuser.com/questions/1570333/how-can-i-record-audio-output-from-command-line-in-linux)
|
||||||
|
11
conf/nbmrec.service
Normal file
11
conf/nbmrec.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=NBMrec daemon nocturnal bird migration service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=1000
|
||||||
|
ExecStart=/usr/local/bin/nmbrec.sh -d night
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
10
conf/nbmrec.timer
Normal file
10
conf/nbmrec.timer
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Record bird migration every night
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* 22:00
|
||||||
|
Unit=nbmrec.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
||||||
|
|
74
src/rec.sh
74
src/rec.sh
@ -8,26 +8,64 @@ RECORD_DIR="/mnt/DATA/media/records"
|
|||||||
RECORD_DATE=$(date +"%Y-%m-%d")
|
RECORD_DATE=$(date +"%Y-%m-%d")
|
||||||
RECORD_FILENAME=$(date +"%Y%m%d_%H%M%S")
|
RECORD_FILENAME=$(date +"%Y%m%d_%H%M%S")
|
||||||
RECORD_FILEPATH="${RECORD_DIR}/${RECORD_DATE}/${RECORD_FILENAME}.wav"
|
RECORD_FILEPATH="${RECORD_DIR}/${RECORD_DATE}/${RECORD_FILENAME}.wav"
|
||||||
RECORD_DURATION=$1
|
RECORD_DURATION=60
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [ -d <duration> ] [ -f <filename> ]"
|
||||||
|
echo " -d <duration> : duration of the recording in seconds or 'night' for all night recording"
|
||||||
|
echo " -f <filename> : filename of the recording"
|
||||||
|
echo " -h : display this help"
|
||||||
|
echo " -v : switch to verbose mode"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get command line options
|
||||||
|
while getopts ":hd:f:" opt; do
|
||||||
|
case $opt in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
RECORD_DURATION=$OPTARG
|
||||||
|
if [ "$RECORD_DURATION" == "night" ]; then
|
||||||
|
RECORD_DURATION=32400
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
RECORD_FILEPATH=$OPTARG
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
echo "Option -$OPTARG requires an argument." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
verbose=false
|
verbose=false
|
||||||
|
|
||||||
# Create output folder
|
main() {
|
||||||
if $verbose
|
# Create output folder
|
||||||
then
|
if $verbose
|
||||||
echo "Creating record output folder"
|
then
|
||||||
fi
|
echo "Creating record output folder"
|
||||||
mkdir -p "$RECORD_DIR/$RECORD_DATE/"
|
fi
|
||||||
|
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
|
rec -b 16 -r 48000 -c 1 -t wav $RECORD_FILEPATH trim 0 $RECORD_DURATION
|
||||||
|
|
||||||
if $verbose
|
if $verbose
|
||||||
then
|
then
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
fi
|
||||||
exit 0
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
exit 0
|
Loading…
x
Reference in New Issue
Block a user