Open konkab opened 2 years ago
Hi. Run this command and try again (https://github.com/homebridge/ffmpeg-for-homebridge/issues/22)
sudo mkdir -p /build/workspace/lib/alsa-lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_conf_pulse.so /build/workspace/lib/alsa-lib/
This script should answer the call when you enable TALK button, and end the call 5 seconds after disable TALK button or closing the application Also, this is a bit confusing. The script doesn't seem to follow this logic. Am I wrong?
I will try to explain
monitor.sh
#!/bin/bash
homebridge_log_path='/var/lib/homebridge/homebridge.log'
doorbell_device_name='Doorbell'
doorbell_ring_repeat=20
count=0
while true;
do
if wget -qO- http://localhost:8000/?/callstat | grep -q "INCOMING"; then
if [[ "$count" -eq "0" ]]; then
wget -q http://localhost:8080/doorbell?$doorbell_device_name > /dev/null 2>&1
((count++))
fi
Send notification to homebridge if baresip has incoming call
tail -100 $homebridge_log_path | awk -v device_name=$doorbell_device_name -v date=`date -d'now' +%d/%m/%Y` -v time=`date -d'now-1 seconds' +%H:%M:%S` '$0~date && $0~time && $0~device_name && /Two-way/ && /time=/ && !/time=00:00:00.00/ {system("wget -q http://localhost:8000/?/accept > /dev/null 2>&1"); exit 1}'
Check homebridge logfile for the last second and find string from ffmpeg contains information about transmitting audio from iphone/ipad. Send command ACCEPT (http://localhost:8000/?/accept) to baresip if found the string
if [ $? -eq 1 ]; then
sleep 1
If command ACCEPT sent
while wget -qO- http://localhost:8000/?/callstat | grep -q "ESTABLISHED";
do
While baresip has active call
tail -100 $homebridge_log_path | awk -v device_name=$doorbell_device_name -v date=`date -d'now' +%d/%m/%Y` -v time1=`date -d'now-1 seconds' +%H:%M:%S` -v time2=`date -d'now-1 seconds' +%H:%M:%S` -v time3=`date -d'now-1 seconds' +%H:%M:%S` -v time4=`date -d'now-4 seconds' +%H:%M:%S` -v time5=`date -d'now-5 seconds' +%H:%M:%S` '($0~date && ($0~time1 || $0~time2 || $0~time3 || $0~time4 || $0~time5) && $0~device_name && /Two-way/ && /time=/ && !/time=00:00:00.00/) {found=1} END {if(!found) system("wget -q http://localhost:8000/?/hangup > /dev/null 2>&1")}'
Check homebridge logfile for last 5 second and find string from ffmpeg contains information about transmitting audio from iphone/ipad. Send command HANGUP (http://localhost:8000/?/hangup) to baresip if NOT found the string
sleep 1
done
elif (( "$count" > $doorbell_ring_repeat )); then
count=0
else
((count++))
fi
else
count=0
fi
sleep 1
done
@spbroot thanks for help!
I created the symlink to the .so file, but it's located under another path. Correct fix for missing .so file:
sudo mkdir -p /build/workspace/lib/alsa-lib/
sudo ln -s /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_conf_pulse.so /build/workspace/lib/alsa-lib/
This error has gone, but it still says "Unknown PCM sipdoorbell_return" and "[alsa @ 0x37e2100] [error] cannot open audio device sipdoorbell_return (No such file or directory)":
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Input #0, sdp, from 'pipe:':
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Metadata:
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] title : Talk
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Duration: N/A, start: 0.000000, bitrate: N/A
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Stream #0:0: Audio: aac, 16000 Hz, mono, s16
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Stream mapping:
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Stream #0:0 -> #0:0 (aac (libfdk_aac) -> pcm_s16le (native))
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [graph_0_in_0_0 @ 0x37b3bf0] [verbose] tb:1/16000 samplefmt:s16 samplerate:16000 chlayout:0x4
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [format_out_0_0 @ 0x37b4110] [verbose] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_0'
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [auto_resampler_0 @ 0x37b5300] [verbose] ch:1 chl:mono fmt:s16 r:16000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [libfdk_aac @ 0x3b600d0] [warning] Queue input is backward in time
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [info] frame= 245 fps= 36 q=-1.0 size= 2536kB time=00:00:08.16 bitrate=2542.7kbits/s speed=1.21x
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sipdoorbell_return
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [AVIOContext @ 0x375fe30] [verbose] Statistics: 358 bytes read, 0 seeks
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [info] Conversion failed!
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [alsa @ 0x37e2100] [error] cannot open audio device sipdoorbell_return (No such file or directory)
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [error] Could not write header for output file #0 (incorrect codec parameters ?): Input/output error
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] [error] Error initializing output stream 0:0 --
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] [Two-way] FFmpeg exited with code: 1 and signal: null (Error)
[1/13/2022, 10:29:31 PM] [Camera FFmpeg] [Вход в подъезд] Stopped video stream.
Any other thoughts?
I will try to explain
monitor.sh
I got your idea now. You're scanning the log for events when two-way audio stream starts and stops.
I'm currently testing MQTT (which Baresip supports out of the box) solution instead of HTTP notifications without needing to fetch log every 1 second, because MQTT receives all required events (like incoming calls) from Baresip momentarily. To accept / hand up call I made a small tweak to camera-ffmeg plugin to send a corresponding MQTT command on startStream
and stopStream
to Baresip to do the thing.
I can confirm MQTT and two way audio works perfect! I was able to fix sipdoorbell_return
error by replacing it with hw:0,0
in return audio params. @spbroot, thank you again for sharing the instructions!
Hi. Great!
I think you need to check reason error sipdoorbell_return
, because if you use hw:0,0
you will crash ffmpeg when open doorbell device in Homekit App on another iphone/ipad at the same time.
Can you give result of 2 commands:
aplay -l
arecord -l
aplay -l
:
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 2: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 3: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
arecord -l
:
**** List of CAPTURE Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
Thank you. Please, send also:
aplay --list-pcms
arecord --list-pcms
aplay --list-pcms
:
null
Discard all samples (playback) or generate zero samples (capture)
default
Playback/recording through the PulseAudio sound server
lavrate
Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
loop_out
loop_in
sipdoorbell_return
sipdoorbell_main
hw:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Direct hardware device without any conversions
hw:CARD=Loopback,DEV=1
Loopback, Loopback PCM
Direct hardware device without any conversions
plughw:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Hardware device with all software conversions
plughw:CARD=Loopback,DEV=1
Loopback, Loopback PCM
Hardware device with all software conversions
sysdefault:CARD=Loopback
Loopback, Loopback PCM
Default Audio Device
front:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Front output / input
surround21:CARD=Loopback,DEV=0
Loopback, Loopback PCM
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Loopback,DEV=0
Loopback, Loopback PCM
4.0 Surround output to Front and Rear speakers
surround41:CARD=Loopback,DEV=0
Loopback, Loopback PCM
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Loopback,DEV=0
Loopback, Loopback PCM
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Loopback,DEV=0
Loopback, Loopback PCM
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Loopback,DEV=0
Loopback, Loopback PCM
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Direct sample mixing device
dmix:CARD=Loopback,DEV=1
Loopback, Loopback PCM
Direct sample mixing device
usbstream:CARD=Loopback
Loopback
USB Stream Output
hw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Hardware device with all software conversions
sysdefault:CARD=Headphones
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
dmix:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample mixing device
usbstream:CARD=Headphones
bcm2835 Headphones
USB Stream Output
hw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Hardware device with all software conversions
sysdefault:CARD=vc4hdmi0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi0,DEV=0
vc4-hdmi-0, MAI PCM i2s-hifi-0
Direct sample mixing device
usbstream:CARD=vc4hdmi0
vc4-hdmi-0
USB Stream Output
hw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Hardware device with all software conversions
sysdefault:CARD=vc4hdmi1
vc4-hdmi-1, MAI PCM i2s-hifi-0
Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
HDMI Audio Output
dmix:CARD=vc4hdmi1,DEV=0
vc4-hdmi-1, MAI PCM i2s-hifi-0
Direct sample mixing device
usbstream:CARD=vc4hdmi1
vc4-hdmi-1
USB Stream Output
arecord --list-pcms
:
null
Discard all samples (playback) or generate zero samples (capture)
default
Playback/recording through the PulseAudio sound server
lavrate
Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
loop_out
loop_in
sipdoorbell_return
sipdoorbell_main
hw:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Direct hardware device without any conversions
hw:CARD=Loopback,DEV=1
Loopback, Loopback PCM
Direct hardware device without any conversions
plughw:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Hardware device with all software conversions
plughw:CARD=Loopback,DEV=1
Loopback, Loopback PCM
Hardware device with all software conversions
sysdefault:CARD=Loopback
Loopback, Loopback PCM
Default Audio Device
front:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Front output / input
dsnoop:CARD=Loopback,DEV=0
Loopback, Loopback PCM
Direct sample snooping device
dsnoop:CARD=Loopback,DEV=1
Loopback, Loopback PCM
Direct sample snooping device
usbstream:CARD=Loopback
Loopback
USB Stream Output
usbstream:CARD=Headphones
bcm2835 Headphones
USB Stream Output
usbstream:CARD=vc4hdmi0
vc4-hdmi-0
USB Stream Output
usbstream:CARD=vc4hdmi1
vc4-hdmi-1
USB Stream Output
I'm not sure, but probably PulseAudio is cause of error. I have couple ideas for test.
This error appears on sipdoorbell_return
, but it don't appear on sipdoorbell_main
.
sipdoorbell_return uses hw:Loopback,0,0
(subdevice "0", default)
sipdoorbell_main uses hw:Loopback,0,1
(subdevice "1")
Maybe something uses default subdevice (like PulseAudio)
Try to change subdevice on "2"
change /etc/asound.conf
file
# output device
pcm.loop_out {
type dmix
ipc_key 100001
slave.pcm "hw:Loopback,0,2"
and change .baresip/config file
audio_player alsa,hw:Loopback,0,1
audio_source alsa,hw:Loopback,1,2
audio_alert alsa,hw:Loopback,0,1
reboot and try.
Change /etc/pulse/client.conf
autospawn = no
reboot and try.
OR
sudo systemctl stop pulseaudio
sudo systemctl disable pulseaudio
sudo systemctl mask pulseaudio
reboot and try.
For enable PulseAudio again
sudo systemctl unmask pulseaudio
sudo systemctl start pulseaudio
sudo systemctl enable pulseaudio
Add to /etc/asound.conf
file
defaults.pcm.card 0
defaults.ctl.card 0
reboot and try.
Hi, thank you for the instructions. I'm trying to set this thing up, but I'm getting this error messages when pressing "Talk" button and ffmpeg crashes:
Could you point me out where to look at? Btw, I'm not currently using
sipdoorbell.service
/monitor.sh
since I'm trying to route everything though MQTT. Could this be a reason?Also, this is a bit confusing. The script doesn't seem to follow this logic. Am I wrong?