Allowing multiple RTSP stream urls

(untested)
This commit is contained in:
ehpersonal38
2022-04-25 16:51:04 -04:00
parent ff9f355271
commit 256b405c21
2 changed files with 12 additions and 10 deletions
+9 -9
View File
@@ -65,7 +65,7 @@ if(isset($_GET['submit'])) {
} }
if(isset($_GET["rtsp_stream"])) { if(isset($_GET["rtsp_stream"])) {
$rtsp_stream = $_GET["rtsp_stream"]; $rtsp_stream = str_replace("\r\n", ",", $_GET["rtsp_stream"]);
if(strcmp($rtsp_stream,$config['RTSP_STREAM']) !== 0) { if(strcmp($rtsp_stream,$config['RTSP_STREAM']) !== 0) {
$contents = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents); $contents = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents);
$contents2 = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents2); $contents2 = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents2);
@@ -76,7 +76,7 @@ if(isset($_GET['submit'])) {
exec('sudo systemctl restart birdnet_recording.service'); 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) {
@@ -121,14 +121,14 @@ if(isset($_GET['submit'])) {
$contents2 = preg_replace("/PRIVACY_MODE=.*/", "PRIVACY_MODE=$privacy_mode", $contents2); $contents2 = preg_replace("/PRIVACY_MODE=.*/", "PRIVACY_MODE=$privacy_mode", $contents2);
if(strcmp($privacy_mode,"on") == 0) { if(strcmp($privacy_mode,"on") == 0) {
exec('sudo sed -i \'s/\/usr\/local\/bin\/server.py/\/usr\/local\/bin\/privacy_server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service'); exec('sudo sed -i \'s/\/usr\/local\/bin\/server.py/\/usr\/local\/bin\/privacy_server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service');
exec('sudo systemctl daemon-reload'); exec('sudo systemctl daemon-reload');
exec('restart_services.sh'); exec('restart_services.sh');
header('Location: /log'); header('Location: /log');
} elseif(strcmp($privacy_mode,"off") == 0) { } elseif(strcmp($privacy_mode,"off") == 0) {
exec('sudo sed -i \'s/\/usr\/local\/bin\/privacy_server.py/\/usr\/local\/bin\/server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service'); exec('sudo sed -i \'s/\/usr\/local\/bin\/privacy_server.py/\/usr\/local\/bin\/server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service');
exec('sudo systemctl daemon-reload'); exec('sudo systemctl daemon-reload');
exec('restart_services.sh'); exec('restart_services.sh');
header('Location: /log'); header('Location: /log');
} }
} }
} }
@@ -215,7 +215,7 @@ if (file_exists('./scripts/thisrun.txt')) {
<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> <label for="rtsp_stream">RTSP Stream: </label>
<input name="rtsp_stream" type="url" value="<?php print($newconfig['RTSP_STREAM']);?>" /><br> <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.</p> <p>If you place an RTSP stream URL here, BirdNET-Pi will use that as its audio source.</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>
+3 -1
View File
@@ -6,7 +6,9 @@ source /etc/birdnet/birdnet.conf
if [ ! -z $RTSP_STREAM ];then if [ ! -z $RTSP_STREAM ];then
while true;do while true;do
ffmpeg -i $RTSP_STREAM -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$(date "+%H:%M:%S").wav 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 done
else else
if ! pulseaudio --check;then pulseaudio --start;fi if ! pulseaudio --check;then pulseaudio --start;fi