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
|
||||
|
||||
```bash
|
||||
# Sercices status
|
||||
sudo systemctl status birdnet_recording.service birdnet_analyzis.service
|
||||
# Timers status
|
||||
sudo systemctl status birdnet_miner.timer
|
||||
# Sercices and timers status
|
||||
sudo systemctl status birdnet_\*
|
||||
```
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
### Install php 8.1
|
||||
|
@ -3,6 +3,7 @@
|
||||
DEBUG=${DEBUG:-1}
|
||||
|
||||
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() {
|
||||
if [ $DEBUG -eq 1 ]; then
|
||||
@ -27,20 +28,25 @@ record_loop() {
|
||||
done
|
||||
}
|
||||
|
||||
FFMPEG_OPTIONS="-nostdin -hide_banner -loglevel error -nostats -vn -acodec pcm_s16le -ac 1 -ar 48000 "
|
||||
|
||||
record_stream() {
|
||||
local STREAM=$1
|
||||
local DURATION=$2
|
||||
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() {
|
||||
DEVICE=$1
|
||||
DURATION=$2
|
||||
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"
|
||||
|
@ -6,4 +6,4 @@ OnCalendar=*:0/15
|
||||
Unit=birdnet_miner.service
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
WantedBy=timers.target
|
@ -5,7 +5,7 @@ set -e
|
||||
|
||||
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}
|
||||
BRANCH=${BRANCH:-main}
|
||||
WORKDIR="$(pwd)/BirdNET-stream"
|
||||
@ -48,7 +48,7 @@ install_birdnetstream() {
|
||||
# Clone BirdNET-stream
|
||||
cd "$WORKDIR"
|
||||
debug "Cloning BirdNET-stream from $REPOSITORY"
|
||||
git clone -b "$BRANCH"--recurse-submodules "$REPOSITORY" .
|
||||
git clone -b "$BRANCH" --recurse-submodules "$REPOSITORY" .
|
||||
debug "Creating python3 virtual environment $PYTHON_VENV"
|
||||
python3 -m venv $PYTHON_VENV
|
||||
debug "Activating $PYTHON_VENV"
|
||||
@ -219,6 +219,8 @@ main() {
|
||||
install_web_interface
|
||||
setup_http_server
|
||||
install_config
|
||||
debug "Run loginctl enable-linger for $USER"
|
||||
loginctl enable-linger
|
||||
update_permissions
|
||||
debug "Installation done"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user