Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doorbird camera discussion #1060

Open
AlexxIT opened this issue Apr 23, 2024 · 53 comments
Open

Doorbird camera discussion #1060

AlexxIT opened this issue Apr 23, 2024 · 53 comments
Assignees
Labels
camera Discussion on a particular camera model

Comments

@AlexxIT
Copy link
Owner

AlexxIT commented Apr 23, 2024

@AlexxIT AlexxIT added the camera Discussion on a particular camera model label Apr 23, 2024
@oeiber
Copy link
Contributor

oeiber commented May 4, 2024

Hi,
how can I help to integrate backchannel audio for doorbird devices?

@AlexxIT
Copy link
Owner Author

AlexxIT commented May 4, 2024

Developing two way without physical access to device is very hard task. There is no feedback.
Theoretically only possible if there is some other camera nearby that I can watch and hear through.

@oeiber
Copy link
Contributor

oeiber commented May 4, 2024

I'll give you access to my device. Here's the link to the api documentation:
Doorbird API
You can find related information on page 18.

@AlexxIT
Copy link
Owner Author

AlexxIT commented May 4, 2024

I also need yet another camera for feedback.

@fergalom
Copy link

I'll give you access to my device. Here's the link to the api documentation: Doorbird API You can find related information on page 18.

@oeiber I can help also as requested

@oeiber
Copy link
Contributor

oeiber commented May 14, 2024

@oeiber I can help also as requested

I configured an public endpoint for Alex using nginx. Now he should be able access Doorbird's api. But Alex requested a second camera in the front of Doorbird device to test 2way audio.
Unfortunately I don't have a second device.
@fergalom May I ask you if you have a second camera, which you can place in front of your Doorbird?

@Gis70
Copy link

Gis70 commented Sep 4, 2024

Hello, what do you need exactly, i own a doorbird too.

@fransiouz
Copy link

I also have a doorbird if I can help. On my side both video and audio receive work well. But not microphone.

@fransiouz
Copy link

There is a plugin in scrypted.app for doobird which seems to support audio transmit. Can it help ?
https://github.com/koush/scrypted/tree/main/plugins/doorbird

@luke17287
Copy link

I also have a doorbird and would love this feature.

@fransiouz
Copy link

I switch to something else to do the trick. Doorbird has SIP capability that is working very well : https://www.doorbird.com/fr/sip.
I installed asterisk add-on on HA + sip hass card + asterisk integration : https://tech7fox.github.io/sip-hass-docs/
Finally, I use frigate/go2rtc for the video flow and SIP for bidirectionnal audio. Everything is perfect !!

@luke17287
Copy link

luke17287 commented Nov 19, 2024

Thank you - sounds great.
I also tried a bit with SIP but im a noob and was not able to get it running;) .Ill try with your guide.

@fransiouz
Copy link

Yes, same for me, but I succeed. Forum/discord + chatgpt help...
I can share you some config if needed

@luke17287
Copy link

@fransiouz: I get crazy with asterisk. Iam not able to get my doorbird registered after several hours. I would appreciate if you could share your asterisk custom config files (extensions.conf / pjsip.conf / sip.conf)?

@fransiouz
Copy link

Here is my config. The main point is that it's not the doorbird that initiate the call, but your HA user from your phone or tablet. I created a HA user for my tablet where i have HA installed where I can initiate the call with the SIP CARD. In asterisk add-on, I set up a AMI password + auto add extensions. It will create an extension for the tablet user (in my case extension 102). Then you need to copy some conf files :
/homeassistant/asterisk/custom/extensions.conf

[default]
exten => _X!,1,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})})

/homeassistant/asterisk/custom/pjsip_custom.conf

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060

[transport-wss]
type=transport
protocol=wss
bind=0.0.0.0

;choose an extension number for the doorbird
[6001]
type=endpoint
transport=transport-udp
context=default
disallow=all
allow=ulaw
auth=6001
aors=6001

[6001]
type=auth
auth_type=userpass
password=PASSWORD_TO_SET_IN_DOORBIRD
username=6001

[6001]
type=aor
max_contacts=1
contact=sip:6001@IP_DOORBIRD:5060

/homeassistant/asterisk/custom/confbridge.conf
Not sure if necessary, but it's there...

[general]
; Don't delete, required by asterisk

; Privileged HA users that respond to calls
[admin_user]
type=user
marked=yes
admin=yes
music_on_hold_when_empty=false
quiet=yes
hear_own_join_sound=no
send_events=yes

; Unprivileged doorbell user that initiates calls
[default_user]
type=user
send_events=yes
music_on_hold_when_empty=yes
quiet=yes
hear_own_join_sound=no
wait_marked=yes
end_marked=yes
timeout=300 ;5 minute max call time, set to 0 to make it unlimited

; Set up a conference bridge for each doorbell like this:
[doorbird]
type=bridge
max_members=10
enable_events=yes

Then, in doorbird apps, you need to configure and authorize SIP calls:
Administration /Favorites/Calls SIP ==> you need to add the HA users that are able to call the doorbird. For my tablet, i have added 102@IP_HOMEASSISTANT

Administration/SIP Parameters.
Activate SIP with IP where asterisk is installed (normally HA IP)
SIP users = 6001
Password SIP = same pass than in pjsip_custom.conf

Check Authorize calls IN and add your tablet (102@HA_IP) in Activated SIP users.
When you save this config in doorbird APPS, you should see in asterisk addon logs sip:6001@IPDOORBIRD is added.

Finally, in HA fronted, I added the sip card to be able to call the doorbird :

- type: custom:sipjs-card
    server: ASTERISK_IP
    port: "443" <== don't remember the default port
    video: false
    button_size: "62"
    prefix: ""
    custom:
      - name: Doorbell
        number: "6001"
        icon: mdi:doorbell
        camera: camera.doorbird
    extensions:
      - person: person.tablet
        name: Tablet
        extension: "102"
        secret: AUTO_ADD_PASSWORD

My whole setup is in https. You may have issues without https to be able to activate mic within the apps. But check the logs in asterisk add-on to see if the call is initiate or not.

Hope it help !
Keep me in touch

@luke17287
Copy link

luke17287 commented Nov 20, 2024

Thanks for your great support. I finally got my doorbird connected without any issues. But im forcing the SSL error. I think this could connected to your "whole setup in https". How do you generate your SSL Certifiacte for HAAS? I tried to connect to https://HA-IP:8089/ws to temporarily fix it, but still the same issue.

Acutally I use "Generate SSL Certificate" in the addon config.

Asterisk Addon Logs:
[Nov 20 20:47:08] ERROR[2383]: iostream.c:663 ast_iostream_start_tls: Problem setting up ssl connection: error:00000001:lib(0)::reason(1), Internal SSL error [Nov 20 20:47:08] ERROR[2383]: tcptls.c:179 handle_tcptls_connection: Unable to set up ssl connection with peer '192.168.178.83:57840' [Nov 20 20:47:08] ERROR[2383]: iostream.c:563 ast_iostream_close: SSL_shutdown() failed: error:00000001:lib(0)::reason(1), Internal SSL error

Further i got an frontend issue. Not sure if this is connected to the ssl issue or a seperat task:
image

type: custom:sipjs-card
server:
port: "8089"
video: false
button_size: "62"
prefix: ""
custom:
name: Doorbell
number: "6001"
icon: mdi:doorbell
camera: camera.doorbird
extensions:
'- person: person.me
name: me
extension: "100"
secret: "Auto Add Secret from addon"
'- person: person.wife
name: wife
extension: "101"
secret: "Auto Add Secret from addon"

@oeiber
Copy link
Contributor

oeiber commented Nov 20, 2024

After investing some time with my colleague, here is our current status regarding backchannel audio with doorbird devices:
ffmpeg does not send "Content-Lenght: 99999" header, which is needed to keep the stream open.
The following go code streams pipeline inputs to the doorbird device:

package main

import (
	"bufio"
	"flag"
	"fmt"
	"net"
	"os"
	"time"
)

type DoorbirdClient struct {
	host      string
	port      string
	httpUser  string
	httpPass  string
	maxRateKB int
	conn      net.Conn
}

func NewDoorbirdClient(host, port, httpUser, httpPass string, maxRateKB int) *DoorbirdClient {
	return &DoorbirdClient{
		host:      host,
		port:      port,
		httpUser:  httpUser,
		httpPass:  httpPass,
		maxRateKB: maxRateKB,
	}
}

func (d *DoorbirdClient) doConnect() {
	var err error
	d.conn, err = net.Dial("tcp", d.host+":"+d.port)
	if err != nil {
		fmt.Println("Error connecting to target server:", err)
		return
	}
	defer d.conn.Close()

	fmt.Printf("Connected to %s:%s\n", d.host, d.port)

	postHeader := fmt.Sprintf("POST /bha-api/audio-transmit.cgi?http-user=%s&http-password=%s HTTP/1.0\r\n", d.httpUser, d.httpPass)
	headers := []string{
		postHeader,
		"Content-Type: audio/basic",
		"Connection: Keep-Alive",
		"Cache-Control: no-cache",
		"Content-Length: 999999",
		"",
	}
	for _, header := range headers {
		if _, err := d.conn.Write([]byte(header + "\r\n")); err != nil {
			fmt.Println("Error sending header:", err)
			return
		}
	}

	d.receiveAndSendData()
}

func (d *DoorbirdClient) receiveAndSendData() {
	bufferSize := 1024
	maxBytesPerSecond := d.maxRateKB * 1024
	reader := bufio.NewReader(os.Stdin)

	for {
		data := make([]byte, bufferSize)
		n, err := reader.Read(data)
		if err != nil {
			if err.Error() == "EOF" {
				break
			}
			fmt.Println("Error reading data:", err)
			return
		}

		if n == 0 {
			break
		}

		if _, err := d.conn.Write(data[:n]); err != nil {
			fmt.Println("Error sending data:", err)
			return
		}

		timeToWait := float64(n) / float64(maxBytesPerSecond)
		time.Sleep(time.Duration(timeToWait * float64(time.Second)))
	}

	fmt.Println("Finished sending all received data.")
}

func main() {
	host := flag.String("host", "10.10.10.10", "Target host")
	port := flag.String("port", "80", "Target port")
	httpUser := flag.String("user", "user", "HTTP user")
	httpPass := flag.String("pass", "pass", "HTTP password")
	maxRateKB := flag.Int("rate", 8, "Maximum rate in KB/s")

	flag.Parse()

	client := NewDoorbirdClient(*host, *port, *httpUser, *httpPass, *maxRateKB)
	client.doConnect()
}

example:
ffmpeg -fflags nobuffer -f alaw -ar 8000 -i test.wav -ac 1 -ar 8000 -f mulaw - | go run main.go -host 123.123.123.123 -port 80 -user user -pass password

As far as i know, tapo devices are working very similar, don't they?

@AlexxIT Maybe this code can be modified and added directly to go2rtc?

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 21, 2024

This is hard to do because there is no way I can test this code at all

@oeiber
Copy link
Contributor

oeiber commented Nov 21, 2024

Ok. I'll give you access to my dorbird device and will bring a notebook with microphone and speaker in front of it.

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 21, 2024

I think this should work

@oeiber
Copy link
Contributor

oeiber commented Nov 21, 2024

perfect! when would it be convenient for you?

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 21, 2024

It's hard to say. We could try this weekend.

@oeiber
Copy link
Contributor

oeiber commented Nov 21, 2024

sounds good! what do you need to access the windows notebook?

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 21, 2024

Any messenger from my contacts. Just voice call.

AlexxIT added a commit that referenced this issue Nov 24, 2024
@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 24, 2024

Thanks to @oeiber new source added to master version. Will be in next release:

streams:
  video-audio:
    - rtsp://user:[email protected]:554/mpeg/media.amp
    - doorbird://user:[email protected]?media=audio
  two-way:
    - rtsp://user:[email protected]:554/mpeg/media.amp
    - doorbird://user:[email protected]?media=audio
    - doorbird://user:[email protected]
  mjpeg-video:
    - doorbird://user:[email protected]?media=video

@oeiber
Copy link
Contributor

oeiber commented Nov 24, 2024

Unfortunately backchannel audio is not working for me, yet:

Configuration:

streams:
  spa01:
    - rtsp://user:[email protected]:8557/mpeg/720p/media.amp
    - doorbird://user:[email protected]?media=audio
    - doorbird://user:[email protected]

Stream info:

{
  "producers": [
    {
      "id": 7998,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "192.168.178.13:8557",
      "url": "rtsp://user:[email protected]:8557/mpeg/720p/media.amp",
      "sdp": "v=0\r\no=- 1731313804359174 1 IN IP4 192.168.178.13\r\ns=RTSP/RTP stream from DoorBird\r\ni=mpeg/720p/media.amp\r\nt=0 0\r\na=tool:LIVE555 Streaming Media v2024.05.15\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:RTSP/RTP stream from DoorBird\r\na=x-qt-text-inf:mpeg/720p/media.amp\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:2\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=4D0028;sprop-parameter-sets=Z00AKNoBQBbpUgAAAwDwAAA4QMCAAehIAAiVRe98LwiEag==,aO48gA==\r\na=control:track1\r\n",
      "user_agent": "go2rtc/1.9.7",
      "medias": [
        "video, recvonly, H264"
      ],
      "receivers": [
        {
          "id": 7999,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 40,
            "profile": "Main"
          },
          "childs": [
            8000
          ],
          "bytes": 7104992,
          "packets": 5426
        }
      ],
      "bytes_recv": 7171280
    },
    {
      "id": 8001,
      "format_name": "pcm",
      "protocol": "http",
      "remote_addr": "192.168.178.13",
      "url": "http://user:[email protected]/bha-api/audio-receive.cgi?media=audio",
      "medias": [
        "audio, recvonly, PCMU/8000"
      ],
      "receivers": [
        {
          "id": 8005,
          "codec": {
            "codec_name": "pcm_mulaw",
            "codec_type": "audio",
            "sample_rate": 8000
          },
          "childs": [
            8006
          ],
          "bytes": 758784,
          "packets": 741
        }
      ],
      "bytes_recv": 758784
    },
    {
      "id": 25465,
      "format_name": "doorbird",
      "protocol": "http",
      "url": "http://192.168.178.13/bha-api/audio-transmit.cgi?http-user=user\u0026http-password=password",
      "medias": [
        "audio, sendonly, PCMU/8000"
      ],
      "senders": [
        {
          "id": 25466,
          "codec": {
            "codec_name": "pcm_mulaw",
            "codec_type": "audio",
            "sample_rate": 8000
          },
          "parent": 8003
        }
      ]
    }
  ],
  "consumers": [
    {
      "id": 7997,
      "format_name": "webrtc",
      "protocol": "ws+udp",
      "remote_addr": "192.168.178.105:61586 host",
      "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2024.11 (io.robbie.HomeAssistant; build:2024.971; iOS 18.0.1) Mobile/HomeAssistant, like Safari",
      "medias": [
        "video, sendonly, H264, H265, VP8, VP9",
        "audio, recvonly, OPUS/48000/2, G722/8000, PCMU/8000, PCMA/8000",
        "audio, sendonly, OPUS/48000/2, G722/8000, PCMU/8000, PCMA/8000, L16, PCML"
      ],
      "receivers": [
        {
          "id": 8003,
          "codec": {
            "codec_name": "pcm_mulaw",
            "codec_type": "audio",
            "sample_rate": 8000
          },
          "childs": [
            25466
          ],
          "bytes": 375520,
          "packets": 2347
        }
      ],
      "senders": [
        {
          "id": 8000,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video"
          },
          "parent": 7999,
          "bytes": 7104992,
          "packets": 5426
        },
        {
          "id": 8006,
          "codec": {
            "codec_name": "pcm_mulaw",
            "codec_type": "audio",
            "sample_rate": 8000
          },
          "parent": 8005,
          "bytes": 758784,
          "packets": 741
        }
      ],
      "bytes_recv": 424420,
      "bytes_send": 7952220
    }
  ]
}

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 24, 2024

Maybe you have some errors in logs? The device supports only one connection. I've experienced a number of failures in testing.

@oeiber
Copy link
Contributor

oeiber commented Nov 24, 2024

I can see a lot of retries in the logs.
My college did also some testing with transfering audio to doorbird devices. He finally ended up with using a tcp socket instead of http. He also meantioned, it would be neccacary to implement some rate control, because of doorbird's weak tcp buffering behaviour:

package main

import (
	"bufio"
	"flag"
	"fmt"
	"net"
	"os"
	"time"
)

type DoorbirdClient struct {
	host      string
	port      string
	httpUser  string
	httpPass  string
	maxRateKB int
	conn      net.Conn
}

func NewDoorbirdClient(host, port, httpUser, httpPass string, maxRateKB int) *DoorbirdClient {
	return &DoorbirdClient{
		host:      host,
		port:      port,
		httpUser:  httpUser,
		httpPass:  httpPass,
		maxRateKB: maxRateKB,
	}
}

func (d *DoorbirdClient) doConnect() {
	var err error
	d.conn, err = net.Dial("tcp", d.host+":"+d.port)
	if err != nil {
		fmt.Println("Error connecting to target server:", err)
		return
	}
	defer d.conn.Close()

	fmt.Printf("Connected to %s:%s\n", d.host, d.port)

	postHeader := fmt.Sprintf("POST /bha-api/audio-transmit.cgi?http-user=%s&http-password=%s HTTP/1.0\r\n", d.httpUser, d.httpPass)
	headers := []string{
		postHeader,
		"Content-Type: audio/basic",
		"Connection: Keep-Alive",
		"Cache-Control: no-cache",
		"Content-Length: 999999",
		"",
	}
	for _, header := range headers {
		if _, err := d.conn.Write([]byte(header + "\r\n")); err != nil {
			fmt.Println("Error sending header:", err)
			return
		}
	}

	d.receiveAndSendData()
}

func (d *DoorbirdClient) receiveAndSendData() {
	bufferSize := 1024
	maxBytesPerSecond := d.maxRateKB * 1024
	reader := bufio.NewReader(os.Stdin)

	for {
		data := make([]byte, bufferSize)
		n, err := reader.Read(data)
		if err != nil {
			if err.Error() == "EOF" {
				break
			}
			fmt.Println("Error reading data:", err)
			return
		}

		if n == 0 {
			break
		}

		if _, err := d.conn.Write(data[:n]); err != nil {
			fmt.Println("Error sending data:", err)
			return
		}

		timeToWait := float64(n) / float64(maxBytesPerSecond)
		time.Sleep(time.Duration(timeToWait * float64(time.Second)))
	}

	fmt.Println("Finished sending all received data.")
}

func main() {
	host := flag.String("host", "10.10.10.10", "Target host")
	port := flag.String("port", "80", "Target port")
	httpUser := flag.String("user", "user", "HTTP user")
	httpPass := flag.String("pass", "pass", "HTTP password")
	maxRateKB := flag.Int("rate", 8, "Maximum rate in KB/s")

	flag.Parse()

	client := NewDoorbirdClient(*host, *port, *httpUser, *httpPass, *maxRateKB)
	client.doConnect()
}

What do you think?

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 25, 2024

  • go2rtc also uses raw TCP connection
  • it's not about buffering, but about real time

@kevp89
Copy link

kevp89 commented Nov 25, 2024

Hi Alex. Although i am not firm in go it seems your send method is using the native http go client, which uses HTTP/1.1 instead of HTTP/1.0 as Protocol.
Which in Turn does not allow to set a custom content-length size.
That's why Oliver and me tried this implementation with a native socket instead of the go http client.

i captured the post request to the doorbird which reflects these findings:
Content-Length is set to 0 and i can see a new TCP Connection to the camera for each Chunk that is being sent. This starves the Network Stack of the camera and it soon starts running out of TCP Ports for new connections.

POST /bha-api/audio-transmit.cgi?http-user=USER&http-password=PASSWORD HTTP/1.1
Host: 10.200.13.114
User-Agent: Go-http-client/1.1
Content-Length: 0
Cache-Control: no-cache
Connection: Keep-Alive
Content-Type: audio/basic

HTTP/1.0 503 Service Not Available
Content-Type: text/html
Content-Length: 365
Connection: keep-alive
Date: Mon, 25 Nov 2024 08:58:59 GMT
Server: lighttpd

<title>503 Service Not Available</title>

503 Service Not Available

Best Regards,
Kevin

@AlexxIT
Copy link
Owner Author

AlexxIT commented Nov 25, 2024

@kevp89 Thanks. I don't use standard http client, but I do use standard http request. Maybe that's where the problem is. I'll look into it.

req, err := http.NewRequest("POST", rawURL, nil)
if err != nil {
return nil, err
}
req.Header = http.Header{
"Content-Type": []string{"audio/basic"},
"Content-Length": []string{"9999999"},
"Connection": []string{"Keep-Alive"},
"Cache-Control": []string{"no-cache"},
}
if u.Port() == "" {
u.Host += ":80"
}
conn, err := net.DialTimeout("tcp", u.Host, core.ConnDialTimeout)
if err != nil {
return nil, err
}
_ = conn.SetWriteDeadline(time.Now().Add(core.ConnDeadline))
if err = req.Write(conn); err != nil {
return nil, err
}

@fladenbrotic
Copy link

fladenbrotic commented Dec 1, 2024

Hi @ll,
First come first: Thank you guys for setting this all up to get the doorbirds running with go2rtc

Yesterday I have downloaded the nightly release, and I can confirm I can receive audio now.
However, as soon as I press the microphone button my Doorbird is running into its limits.

Home Assistant still has access to doorbird but I am only barely able to use the app to connect. Also the connection with the doorbird app on my mobile is not working anymore properly. Everything is super slow and I get reoccurring responses to check the data connection. By the way, the microphone path is also not working. Have still only receive path.

  • Resetting the doorbird (plugging out and in from power) doesn’t help to improve.
  • Disabling the microphone in Home Assistant is also not helping.
  • Only when I stop and restart Frigate/go2rtc the doorbird starts to behave properly and all connections are working as expected, again.

Not sure, whether my setup is wrong, but in summary my doorbird is stalled as soon as I activate the microphone and it heals only, when I restart Frigate/go2rtc.

In Frigate I am using the 2-way configuration:

go2rtc part

go2rtc   
   Frontdoor:
      - rtsp://userid:password@myIP:8557/mpeg/720p/media.amp
      - doorbird://userid:password@myIP?media=audio
      - doorbird://userid:password@myIP

cameras part

cameras:
  Frontdoor: 
    enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/Frontdoor?video=all&audio=all 
          input_args: preset-rtsp-restream
          roles:
            - record

Is there anything I can do to support?

@AlexxIT AlexxIT self-assigned this Dec 1, 2024
@luke17287
Copy link

@fladenbrotic which version did you try?

AlexxIT added a commit that referenced this issue Dec 5, 2024
@AlexxIT
Copy link
Owner Author

AlexxIT commented Dec 5, 2024

I have made changes after @kevp89 advice. You can try new master version.

@fladenbrotic
Copy link

fladenbrotic commented Dec 5, 2024

@fladenbrotic which version did you try?

go2rtc platform=linux/arm64 revision=mod.d7cdc8b version=1.9.7

I used a nightly build

@fladenbrotic
Copy link

fladenbrotic commented Dec 5, 2024

I have made changes after @kevp89 advice. You can try new master version.

@AlexxIT,

did download the latest nightly build.

  • go2rtc platform=linux/arm64 revision=mod.d8c0f9d version=1.9.7

unfortunatelly, I do not see any difference.

@fladenbrotic
Copy link

Hi @ll,

I just realized something indeed changed.
Now it is sufficiant to close the browser tab to get it back to normal.

I also realized that now, the microphone is not toggeling in Frigate lovelace card (I am using home assistant). Which means, when I press the mic-symbol it is changing shortly to red and jumps back to the striked-through mic icon. On the other side, the the browser is confirming the mic is in use.

In summary. It seems like the mic is turned on, but Frigate doesn't recognize the same. Closing of the tab is healing the system.

Not sure, if these informatin are helping to circle the issue down.

Regards

@AlexxIT
Copy link
Owner Author

AlexxIT commented Dec 6, 2024

It is better to debug the work in go2rtc WebUI. And if everything is fine there, move on to other software.

@kevp89
Copy link

kevp89 commented Dec 6, 2024

Hi Alex

Unfortunately even with the latest build the error persists.
Currently the producer is started and afterwords it's looping endlessly through the producer.reconnect function.

As far as i know the doorbird does block every client from sending data apart from the first one.

Currently the producer reconnect does spawn a tcp session per reconnect and according to the packet captures there is no voice data in the transmitted request, just the header and afterwards no data.

After several seconds the doorbird closes the connection with "HTTP/200 OK"

13:06:37.056 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.059 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.062 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.065 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.069 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.071 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.075 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.078 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.082 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.085 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.090 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.096 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.099 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.103 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.107 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.110 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.113 DBG [streams] retry=0 to url=doorbird://user:[email protected]
13:06:37.116 DBG [streams] retry=0 to url=doorbird://user:[email protected]

@fladenbrotic
Copy link

Hit @AlexxIT

I checked in the go2rtc WebUI and I see the following warning in the logs.

warn undefined error=unexpected EOF url=doorbird://userid:password@myIP?media=audio caller=github.com/AlexxIT/go2rtc/internal/streams/producer.go:170

and following information how doorbird is set-up in go2rtc
{ "producers": [ { "id": 503, "format_name": "rtsp", "protocol": "rtsp+tcp", "remote_addr": "myIP:8557", "url": "rtsp://userid:password@myIP:8557/mpeg/720p/media.amp", "sdp": "v=0\r\no=- 1731313803606585 1 IN IP4 myIP\r\ns=RTSP/RTP stream from DoorBird\r\ni=mpeg/720p/media.amp\r\nt=0 0\r\na=tool:LIVE555 Streaming Media v2024.05.15\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:RTSP/RTP stream from DoorBird\r\na=x-qt-text-inf:mpeg/720p/media.amp\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:2\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=4D0028;sprop-parameter-sets=Z00AKNoBQBbpUgAAAwDwAAA4QMCAAehIAAiVRe98LwiEag==,aO48gA==\r\na=control:track1\r\n", "user_agent": "go2rtc/1.9.7", "medias": [ "video, recvonly, H264" ], "receivers": [ { "id": 504, "codec": { "codec_name": "h264", "codec_type": "video", "level": 40, "profile": "Main" }, "childs": [ 505, 18933, 20252, 20255 ], "bytes": 2170874995, "packets": 1703772 } ], "bytes_recv": 2191647915 }, { "id": 16104, "format_name": "pcm", "protocol": "http", "remote_addr": "myIP", "url": "http://userid:password@myIP/bha-api/audio-receive.cgi?media=audio", "medias": [ "audio, recvonly, PCMU/8000" ], "receivers": [ { "id": 16105, "codec": { "codec_name": "pcm_mulaw", "codec_type": "audio", "sample_rate": 8000 }, "childs": [ 509, 18934, 20253, 20256 ], "bytes": 2946048, "packets": 2877 } ], "bytes_recv": 2946048 }, { "url": "doorbird://userid:password@myIP" } ], "consumers": [ { "id": 502, "format_name": "rtsp", "protocol": "rtsp+tcp", "remote_addr": "127.0.0.1:33266", "sdp": "v=0\r\no=- 1 1 IN IP4 0.0.0.0\r\ns=go2rtc/1.9.7\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=video 0 RTP/AVP 96\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=4D0028;sprop-parameter-sets=Z00AKNoBQBbpUgAAAwDwAAA4QMCAAehIAAiVRe98LwiEag==,aO48gA==\r\na=control:trackID=0\r\nm=audio 0 RTP/AVP 97\r\na=rtpmap:97 PCMU/8000\r\na=control:trackID=1\r\n", "user_agent": "FFmpeg Frigate/0.14.1-f4f3cfa", "medias": [ "video, sendonly, ALL", "audio, sendonly, ALL" ], "senders": [ { "id": 505, "codec": { "codec_name": "h264", "codec_type": "video", "level": 40, "profile": "Main" }, "parent": 504, "bytes": 2170874995, "packets": 1703772 }, { "id": 509, "codec": { "codec_name": "pcm_mulaw", "codec_type": "audio", "sample_rate": 8000 }, "parent": 16105, "bytes": 305490944, "packets": 298331 } ], "bytes_send": 2508399587 }, { "id": 18932, "format_name": "webrtc", "protocol": "ws+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp", "remote_addr": "192.168.179.20:32985 host", "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "medias": [ "video, sendonly, VP8, VP9, H264, AV1", "audio, sendonly, OPUS/48000/2, G722/8000, PCMU/8000, PCMA/8000, L16, PCML" ], "senders": [ { "id": 18933, "codec": { "codec_name": "h264", "codec_type": "video" }, "parent": 504, "bytes": 4938660, "packets": 4600 }, { "id": 18934, "codec": { "codec_name": "pcm_mulaw", "codec_type": "audio", "sample_rate": 8000 }, "parent": 16105, "bytes": 2337792, "packets": 2283 } ], "bytes_send": 7372813 }, { "id": 20251, "format_name": "mse/fmp4", "protocol": "ws", "remote_addr": "127.0.0.1:42676 forwarded 192.168.179.49, 172.30.32.1", "user_agent": "Mozilla/5.0 (Linux; Android 14; SM-G990B2 Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/131.0.6778.41 Mobile Safari/537.36 Home Assistant/2024.10.3-14058 (Android 14; SM-G990B2)", "medias": [ "video, sendonly, H264, H265", "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, PCML, OPUS" ], "senders": [ { "id": 20252, "codec": { "codec_name": "h264", "codec_type": "video", "level": 40, "profile": "Main" }, "parent": 504, "bytes": 4720766, "packets": 4393 }, { "id": 20253, "codec": { "codec_name": "flac", "codec_type": "audio", "sample_rate": 8000 }, "parent": 16105, "bytes": 2231296, "packets": 2179 } ], "bytes_send": 9687506 }, { "id": 20254, "format_name": "webrtc", "protocol": "ws+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp+udp", "remote_addr": "192.168.179.136:57687 host", "user_agent": "Mozilla/5.0 (Linux; Android 14; SM-G990B2 Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/131.0.6778.41 Mobile Safari/537.36 Home Assistant/2024.10.3-14058 (Android 14; SM-G990B2)", "medias": [ "video, sendonly, VP8, VP9, AV1, H264", "audio, sendonly, OPUS/48000/2, G722/8000, PCMU/8000, PCMA/8000, L16, PCML" ], "senders": [ { "id": 20255, "codec": { "codec_name": "h264", "codec_type": "video" }, "parent": 504, "bytes": 4720766, "packets": 4393 }, { "id": 20256, "codec": { "codec_name": "pcm_mulaw", "codec_type": "audio", "sample_rate": 8000 }, "parent": 16105, "bytes": 2231296, "packets": 2179 } ], "bytes_send": 7044279 } ] }

Does that help?

@luke17287
Copy link

luke17287 commented Dec 11, 2024

First of all thanks to @AlexxIT for your great effort to get the doorbird working ;)

I got the one way audio on live view and on recordings. But the audio is like 10 seconds delayed and the quality is terrible. Im using go2rtc in Frigate as docker and would appreciate if one of you expert guys can check if there are possible faults/improvements in my newbie config. No errors in the logs.

Thanks in advance guys:

Frigate: 0.14.1.-f4f3cfa
Go2rtc: dbe9e4a 1.9.7

go2rtc:
  #log:
    #exec: trace
  ffmpeg:
    input_mulaw: -f mulaw -ar 8000 -i {input}
    noise_filter: -af highpass=200,lowpass=3000,afftdn

  webrtc:
    candidates:
      - 192.168.178.141:8555
      - stun:8555

  streams:
    haustuer:
      - rtsp://user:[email protected]/mpeg/720p/media.amp#media=video
      - ffmpeg:http://192.168.178.108/bha-api/audio-receive.cgi?http-user=user&http-password=password#media=audio#backchannel=0#input=input_mulaw#audio=aac#audio=noise_filter

cameras:
  haustuer:
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-aac
      inputs:
        - path: rtsp://127.0.0.1:8554/haustuer?video=all&audio=all
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect

@AlexxIT
Copy link
Owner Author

AlexxIT commented Dec 12, 2024

You forgot real time flags in your input

"http": "-fflags nobuffer -flags low_delay -i {input}",

@luke17287
Copy link

Is there already a workaround to get the microphone running expect SIP protocol?

@oeiber
Copy link
Contributor

oeiber commented Dec 23, 2024

Hi @AlexxIT,
as @kevp89 already mentioned, the error persists. Using wireshark, I can see there's a new TCP stream, everytime go2rtc loops through the reconnect function. Additionally there's also no voice data inside the stream.
How can I help to solve the problem?

@AlexxIT
Copy link
Owner Author

AlexxIT commented Dec 23, 2024

It's hard to say. It worked when I tested it. It will be possible to retry the remote connection next sunday.

@oeiber
Copy link
Contributor

oeiber commented Dec 28, 2024

It's hard to say. It worked when I tested it. It will be possible to retry the remote connection next sunday.

Hi Alex! Unfortunately Sunday doesn't work for me. Maybe we can find some time a few days later? Thank you!

@LamerTex
Copy link

LamerTex commented Jan 6, 2025

I've also just received my DoorBird doorbell,
I was trying to understand how to use it directly in HomeAssistant also for the 2 way communication and I've found this discussion.
For now, I've set up to display the camera on motion event and to bring up the official DoorBird app when the button is pressed to handle the 2way communication.

When I have some free time in the next weeks I will learn and set up go2rtc and then I can also join you in testing these changes you guys are doing, thanks for your work!

@oeiber
Copy link
Contributor

oeiber commented Jan 10, 2025

I've also just received my DoorBird doorbell, I was trying to understand how to use it directly in HomeAssistant also for the 2 way communication and I've found this discussion. For now, I've set up to display the camera on motion event and to bring up the official DoorBird app when the button is pressed to handle the 2way communication.

When I have some free time in the next weeks I will learn and set up go2rtc and then I can also join you in testing these changes you guys are doing, thanks for your work!

Hi @LamerTex,
maybe you can configure remote access for Alex to get two-way audio finally working?

Thx

Oliver

@LamerTex
Copy link

I've also just received my DoorBird doorbell, I was trying to understand how to use it directly in HomeAssistant also for the 2 way communication and I've found this discussion. For now, I've set up to display the camera on motion event and to bring up the official DoorBird app when the button is pressed to handle the 2way communication.
When I have some free time in the next weeks I will learn and set up go2rtc and then I can also join you in testing these changes you guys are doing, thanks for your work!

Hi @LamerTex, maybe you can configure remote access for Alex to get two-way audio finally working?

Thx

Oliver

Yes, for sure. I wanted to set up go2rtc and learn how it works first because it's the first time I've seen it, and I'm doing that right now.
So if and when @AlexxIT has some time and wants to try anything I will be happy to make the setup available for him.
Just let me know when and how you would like to access and I can prepare the DoorBird camera with a webcam in front of it.

Thanks for your work,
Matteo

@LamerTex
Copy link

LamerTex commented Jan 11, 2025

I've finished setting up go2rtc and learned at least the basics of it.
I'm using "go2rtc version=1.9.8 platform=linux/arm64 revision=199fdd6" as a HomeAssistant Add-on.

I've added to go2rtc a Tapo camera with

camera1: 
  - tapo://admin:UPPERCASE-SHA256@IP

and it is working with 2way audio.

Then I've added the DoorBird camera with

  doorbird:
    - rtsp://user:password@IP:554/mpeg/media.amp
    - doorbird://user:password@IP?media=audio
    - doorbird://user:password@IP

and magically it is also working with 2way audio!

BUT with some problems:

  1. Both cameras:
    As described in the README, the microphone only works for HTTPS connection, this means that for both camera the 2way communication is only working when I use the "external URL" for accessing HomeAssistant (and the go2rtc web interface), if I use the local IP address directly I cannot use HTTPS and in that case only camera->device audio works. This is true for both access from chrome/firefox but also directly from the HomeAssistant app.
    This means that I cannot use the 2way audio if I have no internet because the external URL connection wouldn't work.
    Is there a way to go around this? Maybe it's just my setup that is wrong in some way.

  2. Doorbird camera:
    If I access the stream (both "simple viewer" and "two way audio from camera") in go2rtc, the video quality is MUCH worse compared to the DoorBird app. The strange thing is that if I open the app while I'm watching the stream inside go2rtc the quality immediately "jumps" to the good one I see in the app and then remains good for a while (seems to be after some time like a timeout)

    EDIT: This "jump" also happens if I access the camera stream from HomeAssistant where the DoorBird camera is added with the DoorBird integration

  3. Doorbird camera:
    In the log I see a couple of warnings, not many. I think they happen when I start/stop a stream from inside go2rtc web interface:

    -undefined error=read tcp HomeAssistantIP:35366->DoorBirdIP:554: i/o timeout url=rtsp://user:password@DoorBird:554/mpeg/media.amp caller=github.com/AlexxIT/go2rtc/internal/streams/producer.go:170
    -undefined error=unexpected EOF url=doorbird://user:password@DoorBirdIP?media=audio caller=github.com/AlexxIT/go2rtc/internal/streams/producer.go:170
    

If you want to try anything @AlexxIT I can setup the Tapo camera in front to the DoorBird camera and give you the login data in Telegram whenever you want.

Thanks again!

@AlexxIT
Copy link
Owner Author

AlexxIT commented Jan 12, 2025

You can message me on telegram anytime. We'll decide on the connection time there.

@Piranha1511
Copy link

Piranha1511 commented Jan 31, 2025

Hi,

I've tried different configurations and I get the video stream, but after 2-3 min the ffmpeg stream seams to crash. This happens with the configuration which is mentioned here as well as other options I've tried.

Any idea what could cause this issue and how to fix it?

mqtt:
  host: 10.x.x.x
  user: user
  password: password

ffmpeg:
  hwaccel_args: preset-vaapi

detectors:
  coral:
    type: edgetpu
    device: usb

#Global Object Settings
objects:
  track:
    - person
  filters:
    person:
      min_area: 5000
      max_area: 100000

record:
  enabled: true
  retain:
    days: 2
    mode: motion
  alerts:
    retain:
      days: 20
  detections:
    retain:
      days: 20

go2rtc:
  streams:
#--------------------------------------------------------------------------------------------------------------------
    Hauseingang:
      - rtsp://user:password@ip:8557/mpeg/720p/media.amp
      - doorbird://user:password@ip?media=audio
      - doorbird://user:password@[email protected]
#--------------------------------------------------------------------------------------------------------------------
cameras:
#--------------------------------------------------------------------------------------------------------------------
  Hauseingang:
    enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/Hauseingang?video=all&audio=all
          input_args: preset-rtsp-restream
          roles:
            - detect
#--------------------------------------------------------------------------------------------------------------------
version: 0.15-1
Image

Logs are attached:

frigate-logs (1).txt

frigate-logs.txt

@luke17287
Copy link

hi guys, is there any prgress to get the two way audio running with doorbird? thanks for your great effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
camera Discussion on a particular camera model
Projects
None yet
Development

No branches or pull requests

10 participants