Files
AvianVisitors/scripts/birdnet_recording.sh
T
jaredb7 421902684f Quieten System logs
Attempt to quieten the amount of log noise being generated by some of the birdnet services visible in the syslog and daemon.log

Recording service
When using RTSP streams the recording service  is generating massive amounts of noise in the logs as it's basically outputting all it's startup info and also outputting stream and export info.
- Set the log level to only output errors

Also the birdnet_recoding service script is outputting it;s contents, I assume was doing this because of the set -x option at the beginning,
-Commenting this fixed that issue

Analysis Service
Small change to this it doesn't output a error when it can't find today's recording directory. It's a non issue if your recording via sound card but it pops up a bit when using RTSP streams as that directory is never created.

Livestream Service
Same treatment as the recording service, set log level to error. It was previously set to info and would occasionally output a massive chunk of output.. presumably abut the encoding processes.
2023-04-09 22:26:04 +10:00

61 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Performs the recording from the specified RTSP stream or soundcard
#set -x
source /etc/birdnet/birdnet.conf
# S
LOGGING_LEVEL='error'
[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15
if [ ! -z $RTSP_STREAM ];then
[ -d $RECS_DIR/StreamData ] || mkdir -p $RECS_DIR/StreamData
# Explode the RSPT steam setting into an array so we can count the number we have
RTSP_STREAMS_EXPLODED_ARRAY=(${RTSP_STREAM//,/ })
while true;do
# Original loop
# for i in ${RTSP_STREAM//,/ };do
# ffmpeg -nostdin -i ${i} -t ${RECORDING_LENGTH} -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/StreamData/$(date "+%F")-birdnet-$(date "+%H:%M:%S").wav
# done
# Initially start the count off at 1 - our very first stream
RTSP_STREAMS_STARTED_COUNT=1
FFMPEG_PARAMS=""
# Loop over the streams
for i in "${RTSP_STREAMS_EXPLODED_ARRAY[@]}"
do
# Map id used to map input to output, this is 0 based in ffmpeg decrement
MAP_ID=$((RTSP_STREAMS_STARTED_COUNT-1))
# Build up the parameters to process the RSTP stream, including mapping for the output
FFMPEG_PARAMS+="-vn -thread_queue_size 512 -i ${i} -map ${MAP_ID} -t ${RECORDING_LENGTH} -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/StreamData/$(date "+%F")-birdnet-RTSP_${RTSP_STREAMS_STARTED_COUNT}-$(date "+%H:%M:%S").wav "
# Increment counter
((RTSP_STREAMS_STARTED_COUNT += 1))
done
# Make sure were passing something valid to ffmpeg, ffmpeg will run interactive and control our look by waiting ${RECORDING_LENGTH} between loops
if [ -n "$FFMPEG_PARAMS" ];then
ffmpeg -hide_banner -loglevel $LOGGING_LEVEL -nostdin $FFMPEG_PARAMS
fi
done
else
if ! pulseaudio --check;then pulseaudio --start;fi
if pgrep arecord &> /dev/null ;then
echo "Recording"
else
until grep 5050 <(netstat -tulpn 2>&1);do
sleep 1
done
if [ -z ${REC_CARD} ];then
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\
--use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%H:%M:%S.wav
else
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\
-D "${REC_CARD}" --use-strftime \
${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%H:%M:%S.wav
fi
fi
fi