install: Adding `loginctl enable-linger` for user recording using pulseaudio
This commit is contained in:
parent
8a192ea2b2
commit
9d0cb08792
16
INSTALL.md
16
INSTALL.md
|
@ -79,17 +79,23 @@ sudo systemctl enable --now birdnet_recording.service birdnet_analyzis.service b
|
||||||
#### Check if services are working
|
#### Check if services are working
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Sercices status
|
# Sercices and timers status
|
||||||
sudo systemctl status birdnet_recording.service birdnet_analyzis.service
|
sudo systemctl status birdnet_\*
|
||||||
# Timers status
|
|
||||||
sudo systemctl status birdnet_miner.timer
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# BirdNET-stream logs
|
# BirdNET-stream logs
|
||||||
sudo journalctl -feu {birdnet_recording,birdnet_analyzis}.service
|
sudo journalctl -feu birdnet_\*
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Enable `loginctl-linger` for the user that runs the servuces
|
||||||
|
|
||||||
|
Running:
|
||||||
|
```bash
|
||||||
|
loginctl enable-linger
|
||||||
|
```
|
||||||
|
This allows to use `/run/user/1000/pulse` to record audio using PulseAudio in birdnet_recording.sh.
|
||||||
|
|
||||||
## Setup BirdNET-stream symfony webapp
|
## Setup BirdNET-stream symfony webapp
|
||||||
|
|
||||||
### Install php 8.1
|
### Install php 8.1
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
DEBUG=${DEBUG:-1}
|
DEBUG=${DEBUG:-1}
|
||||||
|
|
||||||
export PULSE_RUNTIME_PATH="/run/user/$(id -u)/pulse/"
|
export PULSE_RUNTIME_PATH="/run/user/$(id -u)/pulse/"
|
||||||
|
FFMPEG_OPTIONS="-nostdin -hide_banner -loglevel error -nostats -vn -acodec pcm_s16le -ac 1 -ar 48000"
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
if [ $DEBUG -eq 1 ]; then
|
if [ $DEBUG -eq 1 ]; then
|
||||||
|
@ -27,20 +28,25 @@ record_loop() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
FFMPEG_OPTIONS="-nostdin -hide_banner -loglevel error -nostats -vn -acodec pcm_s16le -ac 1 -ar 48000 "
|
|
||||||
|
|
||||||
record_stream() {
|
record_stream() {
|
||||||
local STREAM=$1
|
local STREAM=$1
|
||||||
local DURATION=$2
|
local DURATION=$2
|
||||||
local debug "Recording from $STREAM for $DURATION seconds"
|
local debug "Recording from $STREAM for $DURATION seconds"
|
||||||
ffmpeg $FFMPEG_OPTIONS -f -i ${DEVICE} -t ${DURATION} file:${CHUNK_FOLDER}/in/birdnet_$(date "+%Y%m%d_%H%M%S").wav
|
ffmpeg $FFMPEG_OPTIONS -i ${STREAM} -t ${DURATION} file:${CHUNK_FOLDER}/in/birdnet_$(date "+%Y%m%d_%H%M%S").wav
|
||||||
}
|
}
|
||||||
|
|
||||||
record_device() {
|
record_device() {
|
||||||
DEVICE=$1
|
DEVICE=$1
|
||||||
DURATION=$2
|
DURATION=$2
|
||||||
debug "Recording from $DEVICE for $DURATION seconds"
|
debug "Recording from $DEVICE for $DURATION seconds"
|
||||||
ffmpeg $FFMPEG_OPTIONS -f pulse -i ${DEVICE} -t ${DURATION} -af "volume=$RECORDING_AMPLIFY" file:${CHUNK_FOLDER}/in/birdnet_$(date "+%Y%m%d_%H%M%S").wav
|
local ffmpeg_input
|
||||||
|
if [[ "$AUDIO_USE_PULSE" = "true" ]]; then
|
||||||
|
ffmpeg_input="-f pulse -i ${DEVICE}"
|
||||||
|
else
|
||||||
|
ffmpeg_input="-f alsa -i ${DEVICE}"
|
||||||
|
fi
|
||||||
|
ffmpeg $FFMPEG_OPTIONS $ffmpeg_input -t ${DURATION} -af "volume=$RECORDING_AMPLIFY" file:${CHUNK_FOLDER}/in/birdnet_$(date "+%Y%m%d_%H%M%S").wav
|
||||||
}
|
}
|
||||||
|
|
||||||
config_filepath="./config/birdnet.conf"
|
config_filepath="./config/birdnet.conf"
|
||||||
|
|
|
@ -6,4 +6,4 @@ OnCalendar=*:0/15
|
||||||
Unit=birdnet_miner.service
|
Unit=birdnet_miner.service
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=basic.target
|
WantedBy=timers.target
|
|
@ -5,7 +5,7 @@ set -e
|
||||||
|
|
||||||
DEBUG=${DEBUG:-0}
|
DEBUG=${DEBUG:-0}
|
||||||
|
|
||||||
REQUIREMENTS="git wget ffmpeg python3 python3-pip python3-dev python3-venv g{,un}zip sqlite3"
|
REQUIREMENTS="git wget ffmpeg python3 python3-pip python3-dev python3-venv gzip sqlite3"
|
||||||
REPOSITORY=${REPOSITORY:-https://github.com/UncleSamulus/BirdNET-stream.git}
|
REPOSITORY=${REPOSITORY:-https://github.com/UncleSamulus/BirdNET-stream.git}
|
||||||
BRANCH=${BRANCH:-main}
|
BRANCH=${BRANCH:-main}
|
||||||
WORKDIR="$(pwd)/BirdNET-stream"
|
WORKDIR="$(pwd)/BirdNET-stream"
|
||||||
|
@ -219,6 +219,8 @@ main() {
|
||||||
install_web_interface
|
install_web_interface
|
||||||
setup_http_server
|
setup_http_server
|
||||||
install_config
|
install_config
|
||||||
|
debug "Run loginctl enable-linger for $USER"
|
||||||
|
loginctl enable-linger
|
||||||
update_permissions
|
update_permissions
|
||||||
debug "Installation done"
|
debug "Installation done"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue