mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-28 03:14:04 +02:00
Update spectral_analysis.sh
This commit is contained in:
@@ -15,6 +15,8 @@ fi
|
|||||||
[ -z "$RECORDING_LENGTH" ] && RECORDING_LENGTH=15
|
[ -z "$RECORDING_LENGTH" ] && RECORDING_LENGTH=15
|
||||||
[ -d "$RECS_DIR"/StreamData ] || mkdir -p "$RECS_DIR"/StreamData
|
[ -d "$RECS_DIR"/StreamData ] || mkdir -p "$RECS_DIR"/StreamData
|
||||||
|
|
||||||
|
filename="Spectrum_$(date "+%Y-%m-%d_%H:%M").wav"
|
||||||
|
|
||||||
if [ ! -z "$RTSP_STREAM" ];then
|
if [ ! -z "$RTSP_STREAM" ];then
|
||||||
# Explode the RSPT steam setting into an array so we can count the number we have
|
# Explode the RSPT steam setting into an array so we can count the number we have
|
||||||
RTSP_STREAMS_EXPLODED_ARRAY=("${RTSP_STREAM//,/ }")
|
RTSP_STREAMS_EXPLODED_ARRAY=("${RTSP_STREAM//,/ }")
|
||||||
@@ -31,7 +33,7 @@ if [ ! -z "$RTSP_STREAM" ];then
|
|||||||
# Map id used to map input to output (first stream being 0), this is 0 based in ffmpeg so decrement our counter (which is more human readable) by 1
|
# Map id used to map input to output (first stream being 0), this is 0 based in ffmpeg so decrement our counter (which is more human readable) by 1
|
||||||
MAP_ID="$((RTSP_STREAMS_STARTED_COUNT-1))"
|
MAP_ID="$((RTSP_STREAMS_STARTED_COUNT-1))"
|
||||||
# Build up the parameters to process the RSTP stream, including mapping for the output
|
# Build up the parameters to process the RSTP stream, including mapping for the output
|
||||||
FFMPEG_PARAMS+="-vn -thread_queue_size 512 -i ${i} -map ${MAP_ID}:a:0 -t ${RECORDING_LENGTH} -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/StreamData/spectrum.wav "
|
FFMPEG_PARAMS+="-vn -thread_queue_size 512 -i ${i} -map ${MAP_ID}:a:0 -t ${RECORDING_LENGTH} -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/StreamData/$filename "
|
||||||
# Increment counter
|
# Increment counter
|
||||||
((RTSP_STREAMS_STARTED_COUNT += 1))
|
((RTSP_STREAMS_STARTED_COUNT += 1))
|
||||||
done
|
done
|
||||||
@@ -48,10 +50,10 @@ else
|
|||||||
else
|
else
|
||||||
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}"/StreamData/spectrum.wav
|
--use-strftime "${RECS_DIR}"/StreamData/"$filename"
|
||||||
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 "${RECS_DIR}"/StreamData/spectrum.wav
|
-D "${REC_CARD}" --use-strftime "${RECS_DIR}"/StreamData/"$filename"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user