Files
AvianVisitors/scripts/livestream.sh
T
jaredb7 ae94cbc189 Enhancement to allow simultaneous RTSP stream recording
Updated birdnet_recording.sh
With a functional change around how ffmpeg is used to make use if it's functionality to accept multiple input streams and map each to a output file.
Due to the original implementation generating a  filename that contain the date/time streams would be writing to the same file - a small change was make each stream go to it's one file with unique filenames.

Updated livestream.sh & spectrogram.php
The Livestream service would fail if the RTSP stream setting was more than 1 stream (i.e comma separated list of streams)
Made some improvements so streaming is possible from any of the URL's, The Spectrogram page received a new control and some Javascript that allows the user to change between streams, the setting gets saved and the livestream service restarted so it uses's the correct stream.
This control is not visible if there are no RTSP streams configured
By default the livestream service will stream the the first RTSP URL, if the setting is not set or invalid

Updated advanced.php
With a small GUI change around RTSP steam entry by providing a input field for each URL and a button to add more fields.
In the background nothing changes as we use some Javascript to extract the valus entered and fill in the original rtsp_stream value with the correct comma separated string

Updated server.py
To work with the recording filename changes so that the correct filename is stored in the DB

Updated update_birdnet_snippets.sh
To support a new setting RTSP_STREAM_TO_LIVESTREAM on the Spectrogram page and in the livestream service
2023-04-01 22:29:02 +10:00

33 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Live Audio Stream Service Script
source /etc/birdnet/birdnet.conf
if [ -z ${REC_CARD} ];then
echo "Stream not supported"
elif [[ ! -z ${RTSP_STREAM} ]];then
# Explode the RSPT steam setting into an array so we can count the number we have
RSTP_STREAMS_EXPLODED_ARRAY=(${RTSP_STREAM//,/ })
# If for some reason the RTSP_STREAM_TO_LIVESTREAM is not set, then init it to 0 to use the first stream
if [[ -z ${RTSP_STREAM_TO_LIVESTREAM} ]];then
RTSP_STREAM_TO_LIVESTREAM=0
fi
# Get the RSTP stream at the specified array index
SELECTED_RSTP_STREAM=${RSTP_STREAMS_EXPLODED_ARRAY[RTSP_STREAM_TO_LIVESTREAM]}
# If for some reason the RTSP stream url is null
if [[ -z ${SELECTED_RSTP_STREAM} ]];then
# Try select the first stream
SELECTED_RSTP_STREAM=${RSTP_STREAMS_EXPLODED_ARRAY[0]}
fi
ffmpeg -nostdin -loglevel 32 -ac ${CHANNELS} -i ${SELECTED_RSTP_STREAM} -acodec libmp3lame \
-b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \
-f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re
else
ffmpeg -nostdin -loglevel 32 -ac ${CHANNELS} -f alsa -i ${REC_CARD} -acodec libmp3lame \
-b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \
-f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re
fi