@@ -48,6 +48,13 @@ ICE_PWD=birdnetpi
|
|||||||
|
|
||||||
BIRDNETPI_URL=
|
BIRDNETPI_URL=
|
||||||
|
|
||||||
|
#---------------------------- RTSP Stream URL -------------------------------#
|
||||||
|
|
||||||
|
## If RTSP_STREAM is set, the system will use the RTSP stream as its audio
|
||||||
|
## source instead of recording its own audio. If this variable is kept empty,
|
||||||
|
## BirdNET-Pi will default to recording its own audio.
|
||||||
|
|
||||||
|
RTSP_STREAM=
|
||||||
|
|
||||||
#------------------- Mobile Notifications via Pushed.co ---------------------#
|
#------------------- Mobile Notifications via Pushed.co ---------------------#
|
||||||
#____________The two variables below enable mobile notifications_______________#
|
#____________The two variables below enable mobile notifications_______________#
|
||||||
|
|||||||
@@ -64,6 +64,19 @@ if(isset($_GET['submit'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($_GET["rtsp_stream"])) {
|
||||||
|
$rtsp_stream = str_replace("\r\n", ",", $_GET["rtsp_stream"]);
|
||||||
|
if(strcmp($rtsp_stream,$config['RTSP_STREAM']) !== 0) {
|
||||||
|
$contents = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents);
|
||||||
|
$contents2 = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents2);
|
||||||
|
$fh = fopen('/etc/birdnet/birdnet.conf', "w");
|
||||||
|
$fh2 = fopen("./scripts/thisrun.txt", "w");
|
||||||
|
fwrite($fh, $contents);
|
||||||
|
fwrite($fh2, $contents2);
|
||||||
|
exec('sudo systemctl restart birdnet_recording.service');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($_GET["overlap"])) {
|
if(isset($_GET["overlap"])) {
|
||||||
$overlap = $_GET["overlap"];
|
$overlap = $_GET["overlap"];
|
||||||
if(strcmp($overlap,$config['OVERLAP']) !== 0) {
|
if(strcmp($overlap,$config['OVERLAP']) !== 0) {
|
||||||
@@ -201,6 +214,9 @@ if (file_exists('./scripts/thisrun.txt')) {
|
|||||||
<label for="channels">Audio Channels: </label>
|
<label for="channels">Audio Channels: </label>
|
||||||
<input name="channels" type="number" min="1" max="32" step="1" value="<?php print($newconfig['CHANNELS']);?>" required/><br>
|
<input name="channels" type="number" min="1" max="32" step="1" value="<?php print($newconfig['CHANNELS']);?>" required/><br>
|
||||||
<p>Set Channels to the number of channels supported by your sound card. 32 max.</p>
|
<p>Set Channels to the number of channels supported by your sound card. 32 max.</p>
|
||||||
|
<label for="rtsp_stream">RTSP Stream: </label>
|
||||||
|
<textarea name="rtsp_stream" type="url" ><?php print( str_replace(",", "\r\n", $newconfig['RTSP_STREAM']));?></textarea><br>
|
||||||
|
<p>If you place an RTSP stream URL here, BirdNET-Pi will use that as its audio source. If you have multiple streams, each URL should be on its own line.</p>
|
||||||
<label for="recording_length">Recording Length: </label>
|
<label for="recording_length">Recording Length: </label>
|
||||||
<input name="recording_length" oninput="document.getElementsByName('extraction_length')[0].setAttribute('max', this.value);" type="number" min="3" max="60" step="1" value="<?php print($newconfig['RECORDING_LENGTH']);?>" required/><br>
|
<input name="recording_length" oninput="document.getElementsByName('extraction_length')[0].setAttribute('max', this.value);" type="number" min="3" max="60" step="1" value="<?php print($newconfig['RECORDING_LENGTH']);?>" required/><br>
|
||||||
<p>Set Recording Length in seconds between 6 and 60. Multiples of 3 are recommended, as BirdNET analyzes in 3-second chunks.</p>
|
<p>Set Recording Length in seconds between 6 and 60. Multiples of 3 are recommended, as BirdNET analyzes in 3-second chunks.</p>
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
set -x
|
set -x
|
||||||
source /etc/birdnet/birdnet.conf
|
source /etc/birdnet/birdnet.conf
|
||||||
|
|
||||||
if [ "${TIMESTAMP_FORMAT}" == "12" ];then
|
|
||||||
STAMP="%I:%M:%S%P"
|
|
||||||
else
|
|
||||||
STAMP="%H:%M:%S"
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15
|
[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15
|
||||||
|
|
||||||
|
if [ ! -z $RTSP_STREAM ];then
|
||||||
|
while true;do
|
||||||
|
for i in ${RTSP_STREAM//,/ };do
|
||||||
|
ffmpeg -i ${i} -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$(date "+%H:%M:%S").wav </dev/null > /dev/null 2>&1 & sleep 1;
|
||||||
|
done
|
||||||
|
done
|
||||||
|
else
|
||||||
if ! pulseaudio --check;then pulseaudio --start;fi
|
if ! pulseaudio --check;then pulseaudio --start;fi
|
||||||
|
|
||||||
if pgrep arecord &> /dev/null ;then
|
if pgrep arecord &> /dev/null ;then
|
||||||
echo "Recording"
|
echo "Recording"
|
||||||
else
|
else
|
||||||
@@ -19,12 +19,12 @@ else
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
if [ -z ${REC_CARD} ];then
|
if [ -z ${REC_CARD} ];then
|
||||||
|
|
||||||
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\
|
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
|
--use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%H:%M:%S.wav
|
||||||
else
|
else
|
||||||
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\
|
arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\
|
||||||
-D "${REC_CARD}" --use-strftime \
|
-D "${REC_CARD}" --use-strftime \
|
||||||
${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav
|
${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%H:%M:%S.wav
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ source /etc/birdnet/birdnet.conf
|
|||||||
|
|
||||||
# Set Variables
|
# Set Variables
|
||||||
TMPFILE=$(mktemp)
|
TMPFILE=$(mktemp)
|
||||||
ANALYZED=${RECS_DIR}/*/*Analyzed
|
#ANALYZED=${RECS_DIR}/*/*Analyzed
|
||||||
#SCAN_DIRS are all directories marked "Analyzed"
|
#SCAN_DIRS are all directories marked "Analyzed"
|
||||||
SCAN_DIRS=($(find ${ANALYZED} -type d 2>/dev/null | sort ))
|
SCAN_DIRS=($(find $HOME -type d -name '*Analyzed' 2>/dev/null | sort ))
|
||||||
|
|
||||||
for h in "${SCAN_DIRS[@]}";do
|
for h in "${SCAN_DIRS[@]}";do
|
||||||
# The TMPFILE is created from each .csv file BirdNET creates
|
# The TMPFILE is created from each .csv file BirdNET creates
|
||||||
@@ -30,13 +30,14 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
for i in $(find ${h} -name '*csv' 2>/dev/null | sort );do
|
for i in $(find ${h} -name '*csv' 2>/dev/null | sort );do
|
||||||
# Iterates over each '.csv' file found in each "Analyzed" directory
|
# Iterates over each '.csv' file found in each "Analyzed" directory
|
||||||
# to create the TMPFILE
|
# to create the TMPFILE
|
||||||
echo "${i}" | cut -d'/' -f7 >> ${TMPFILE}
|
echo "$(basename ${i})" >> ${TMPFILE}
|
||||||
sort -k1n -t\; "${i}" | awk '!/Start/{print}' >> ${TMPFILE}
|
sort -k1n -t\; "${i}" | awk '!/Start/{print}' >> ${TMPFILE}
|
||||||
done
|
done
|
||||||
|
|
||||||
# The extraction reads each line of the TMPFILE and sets the variables ffmpeg
|
# The extraction reads each line of the TMPFILE and sets the variables ffmpeg
|
||||||
# will use.
|
# will use.
|
||||||
while read -r line;do
|
while read -r line;do
|
||||||
|
echo "Line = $line"
|
||||||
DATE="$(echo "${line}" \
|
DATE="$(echo "${line}" \
|
||||||
| awk -F- '/birdnet/{print $1"-"$2"-"$3}')"
|
| awk -F- '/birdnet/{print $1"-"$2"-"$3}')"
|
||||||
if [ ! -z ${DATE} ];then
|
if [ ! -z ${DATE} ];then
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ ICE_PWD=birdnetpi
|
|||||||
|
|
||||||
BIRDNETPI_URL=
|
BIRDNETPI_URL=
|
||||||
|
|
||||||
|
#---------------------------- RTSP Stream URL -------------------------------#
|
||||||
|
|
||||||
|
## If RTSP_STREAM is set, the system will use the RTSP stream as its audio
|
||||||
|
## source instead of recording its own audio. If this variable is kept empty,
|
||||||
|
## BirdNET-Pi will default to recording its own audio.
|
||||||
|
|
||||||
|
RTSP_STREAM=
|
||||||
|
|
||||||
#------------------- Mobile Notifications via Pushed.co ---------------------#
|
#------------------- Mobile Notifications via Pushed.co ---------------------#
|
||||||
#____________The two variables below enable mobile notifications_______________#
|
#____________The two variables below enable mobile notifications_______________#
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ source /etc/birdnet/birdnet.conf
|
|||||||
|
|
||||||
if [ -z ${REC_CARD} ];then
|
if [ -z ${REC_CARD} ];then
|
||||||
echo "Stream not supported"
|
echo "Stream not supported"
|
||||||
|
elif [[ ! -z ${RTSP_STREAM} ]];then
|
||||||
|
ffmpeg -loglevel 52 -ac ${CHANNELS} -i ${RTSP_STREAM} -acodec libmp3lame \
|
||||||
|
-b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \
|
||||||
|
-f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re
|
||||||
else
|
else
|
||||||
ffmpeg -loglevel 52 -ac ${CHANNELS} -f alsa -i ${REC_CARD} -acodec libmp3lame \
|
ffmpeg -loglevel 52 -ac ${CHANNELS} -f alsa -i ${REC_CARD} -acodec libmp3lame \
|
||||||
-b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \
|
-b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \
|
||||||
|
|||||||
@@ -18,3 +18,6 @@ fi
|
|||||||
if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then
|
if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then
|
||||||
sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
|
sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
|
||||||
fi
|
fi
|
||||||
|
if ! grep RTSP_STREAM /etc/birdnet/birdnet.conf;then
|
||||||
|
sudo -u${USER} echo "RTSP_STREAM=" >> /etc/birdnet/birdnet.conf
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user