From f1ebae64586d23a6a8578489f394c0222ca1403d Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:33:32 -0400 Subject: [PATCH] rtsp adjustments --- scripts/birdnet_recording.sh | 39 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index 0798511..68405c5 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -2,29 +2,28 @@ set -x source /etc/birdnet/birdnet.conf -if [ "${TIMESTAMP_FORMAT}" == "12" ];then - STAMP="%I:%M:%S%P" -else - STAMP="%H:%M:%S" -fi +STAMP="%H:%M:%S" [ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15 -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 +if [ ! -z $RTSP_STREAM ];then + while true;do + ffmpeg -i $RTSP_STREAM -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$STAMP.wav 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-${STAMP}.wav +else + if ! pulseaudio --check;then pulseaudio --start;fi + if pgrep arecord &> /dev/null ;then + echo "Recording" 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-${STAMP}.wav - fi + 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-${STAMP}.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-${STAMP}.wav + fi fi