1b3a31c3ee
After some services were recently quieted down by adjusting the log level for e.g ffmpeg. It would be nice if the user can easily adjust the log level again so that that they can investigate or debug a issue since output is not generated by default, so now the Livestream, Spectrogream and Birdnet Recording have a adjustable log levels to help with this.
43 lines
1.7 KiB
Bash
Executable File
43 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Live Audio Stream Service Script
|
|
source /etc/birdnet/birdnet.conf
|
|
|
|
# Read the logging level from the configuration option
|
|
LOGGING_LEVEL="${LogLevel_LiveAudioStreamService}"
|
|
# If empty for some reason default to log level of error
|
|
[ -z $LOGGING_LEVEL ] && LOGGING_LEVEL='error'
|
|
# Additionally if we're at debug or info level then allow printing of script commands and variables
|
|
if [ "$LOGGING_LEVEL" == "info" ] || [ "$LOGGING_LEVEL" == "debug" ];then
|
|
# Enable printing of commands/variables etc to terminal for debugging
|
|
set -x
|
|
fi
|
|
|
|
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 $LOGGING_LEVEL -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 $LOGGING_LEVEL -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
|