AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
3.77k stars 307 forks source link

Reolink Video Doorbell discussion #331

Open luisiam opened 1 year ago

luisiam commented 1 year ago

The latest FW 1859 enables 2-way audio via ONVIF profile T. I checked with Happytimesoft ONVIF client and 2-way audio works. Is there any chance to get it working in go2rtc?

Output from info page

{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsp://192.168.10.21//",
      "remote_addr": "192.168.10.21:554",
      "user_agent": "go2rtc/1.3.1",
      "medias": [
        "video, recvonly, H.264 High 5.1",
        "audio, recvonly, MPEG4-GENERIC/16000"
      ],
      "receivers": [
        "96 H264, bytes=129455539, senders=1",
        "97 MPEG4-GENERIC/16000, bytes=1984536, senders=1"
      ],
      "recv": 132603331
    },
    {
      "type": "RTSP passive producer",
      "url": "rtsp://localhost:8554/fb75e35d718d1e0379580b00d5fcc0e7",
      "remote_addr": "127.0.0.1:43364",
      "user_agent": "ffmpeg/go2rtc",
      "medias": [
        "audio, recvonly, OPUS/48000/2"
      ],
      "receivers": [
        "96 OPUS/48000/2, bytes=2800207, senders=1"
      ],
      "recv": 2949215
    }
  ],
  "consumers": [
    {
      "type": "RTSP passive consumer",
      "url": "rtsp://localhost:8554/doorbell_test?audio",
      "remote_addr": "127.0.0.1:43354",
      "user_agent": "go2rtc/ffmpeg",
      "medias": [
        "audio, sendonly, ANY"
      ],
      "senders": [
        "96 MPEG4-GENERIC/16000, bytes=1984536, receivers=1"
      ],
      "send": 2046072
    },
    {
      "type": "WebRTC/WebSocket async passive consumer",
      "remote_addr": "tcp4 prflx 192.168.10.183:65337 related :0",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.62",
      "medias": [
        "video, sendonly, VP8, RTX, VP9, H264, AV1, RED, ULPFEC, FLEXFEC-03",
        "audio, recvonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000",
        "audio, sendonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000"
      ],
      "receivers": [
        "111 OPUS/48000/2, bytes=812126, senders=0"
      ],
      "senders": [
        "96 H264, bytes=124447151, receivers=1",
        "96 OPUS/48000/2, bytes=2679873, receivers=1"
      ],
      "recv": 1054116,
      "send": 128596160
    }
  ]
}
spawn451 commented 1 year ago

I have the impression that the connection is OK, when I send the sound the light of the doorbell lights up. And when I launch the web page with the microphone the doorbell light comes on and stays on until I leave the web page. But no sound grrr.

AlexxIT commented 1 year ago

I have one idea. Check it again after build: https://github.com/AlexxIT/go2rtc/actions/runs/4757706966

Dakuon commented 1 year ago

Hi,

I can confirm that I'm getting audio through with b8953e7 There are 2 issues for me now.

Config:

streams:
  reolink:
    rtsp://admin:pass@10.5.7.191:554/h264Preview_01_sub

I also tried to add ffmpeg:reolink#audio=opus, but the result was pretty much the same.

Anyway, here is the rtsp trace from when I tested without the extra config.

21:58:08.630 TRC [rtsp] client request:
DESCRIBE rtsp://10.5.7.191:554/h264Preview_01_sub RTSP/1.0
CSeq: 2
User-Agent: go2rtc/1.3.2
Require: www.onvif.org/ver20/backchannel
Authorization: Digest username="admin", realm="BC Streaming Media", nonce="4bd784a9d9a7d558295dcb45279b99fb", uri="rtsp://10.5.7.191:554/h264Preview_01_sub", response="f9943089f9e011d9465e5c3e28dde9b6"
Accept: application/sdp

21:58:08.979 TRC [rtsp] client response:
RTSP/1.0 200 OK
Cseq: 2
Date: Thu, Apr 20 2023 19:58:08 GMT
Content-Base: rtsp://10.5.7.191/Preview_01_sub/
Content-Type: application/sdp
Content-Length: 740

v=0
o=- 1682020680751669 1 IN IP4 192.168.0.3
s=Session streamed by "preview"
t=0 0
a=tool:BC Streaming Media v202210012022.10.01
a=type:broadcast
a=control:*
a=range:npt=now-
a=x-qt-text-nam:Session streamed by "preview"
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:8192
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=640033;sprop-parameter-sets=Z2QAM6wVFKCgPZA=,aO48sA==
a=recvonly
a=control:track1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:8192
a=rtpmap:97 MPEG4-GENERIC/16000
a=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408;
a=recvonly
a=control:track2
m=audio 0 RTP/AVP 8
a=control:track3
a=rtpmap:8 PCMA/8000
a=sendonly
21:58:08.979 TRC [rtsp] client request:
SETUP rtsp://10.5.7.191/Preview_01_sub/track1 RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
CSeq: 3
Authorization: Digest username="admin", realm="BC Streaming Media", nonce="4bd784a9d9a7d558295dcb45279b99fb", uri="rtsp://10.5.7.191/Preview_01_sub/track1", response="d33fcffc1990db45363faa2a7eba98fe"
User-Agent: go2rtc/1.3.2
Require: www.onvif.org/ver20/backchannel

21:58:09.041 TRC [rtsp] client response:
RTSP/1.0 200 OK
Date: Thu, Apr 20 2023 19:58:08 GMT
Transport: RTP/AVP/TCP;unicast;destination=10.5.6.3;source=10.5.7.191;interleaved=0-1
Session: 2E7FCE43;timeout=65
Cseq: 3

21:58:09.041 TRC [rtsp] client request:
SETUP rtsp://10.5.7.191/Preview_01_sub/track3 RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=4-5
CSeq: 4
Authorization: Digest username="admin", realm="BC Streaming Media", nonce="4bd784a9d9a7d558295dcb45279b99fb", uri="rtsp://10.5.7.191/Preview_01_sub/track3", response="6ca12a9af3cf3db1d622a02c0f074faf"
Session: 2E7FCE43
User-Agent: go2rtc/1.3.2
Require: www.onvif.org/ver20/backchannel

21:58:10.187 TRC [rtsp] client response:
RTSP/1.0 200 OK
Session: 2E7FCE43;timeout=65
Cseq: 4
Date: Thu, Apr 20 2023 19:58:09 GMT
Transport: RTP/AVP/TCP;unicast;destination=10.5.6.3;source=10.5.7.191;interleaved=4-5

21:58:10.194 TRC [rtsp] client request:
PLAY rtsp://10.5.7.191/Preview_01_sub/ RTSP/1.0
CSeq: 5
Authorization: Digest username="admin", realm="BC Streaming Media", nonce="4bd784a9d9a7d558295dcb45279b99fb", uri="rtsp://10.5.7.191/Preview_01_sub/", response="58ffeaa48f6bbed535941a9a60873b0f"
Session: 2E7FCE43
User-Agent: go2rtc/1.3.2
Require: www.onvif.org/ver20/backchannel
Range: npt=0.000-

21:58:10.246 TRC [rtsp] client response:
RTSP/1.0 200 OK
Cseq: 5
Date: Thu, Apr 20 2023 19:58:09 GMT
Range: npt=0.000-
Session: 2E7FCE43
Rtp-Info: url=rtsp://10.5.7.191/Preview_01_sub/track1;seq=27969;rtptime=3088310812,url=rtsp://10.5.7.191/Preview_01_sub/track2;seq=0;rtptime=0,url=rtsp://10.5.7.191/Preview_01_sub/track3;seq=0;rtptime=0
AlexxIT commented 1 year ago

What about other users test?

spawn451 commented 1 year ago

Same observation using the 3bddeab commit. There is audio delay, noise and video lag. If I try to open the stream at the same time with VLC I got the error below (works fine with scrypted + HomeKit) : It's as if the bandwidth was saturated at a given time. And the video cuts out on go2rtc & VLC With Scrypted+Homekit launched alongside VLC the sound quality is good on both sides.

(I made all my test on Windows & Linux Docker)

19:55:08.044 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:155 > error="read tcp 192.168.10.11:50862->192.168.10.51:554: read: connection reset by peer" url=rtsp://admin:password@192.168.10.51:554/h264Preview_01_sub 19:55:08.044 DBG [streams] retry=0 to url=rtsp://admin:password@192.168.10.51:554/h264Preview_01_sub 19:55:08.045 DBG [streams] producer=dial tcp 192.168.10.51:554: connect: connection refused 19:55:09.045 DBG [streams] retry=1 to url=rtsp://admin:password@192.168.10.51:554/h264Preview_01_sub 19:55:09.047 DBG [streams] producer=dial tcp 192.168.10.51:554: connect: connection refused

I know the mechanism is different with scrypted(rtp>udp?), I also tried to adapt the ffmpeg parameter with this

[HomeKit]: -hide_banner -i rtsp:[REDACTED] -acodec libopus -application lowdelay -frame_duration 20 -flags +global_header -ar 24k -b:a 24k -bufsize 96k -ac 1 -payload_type 110 -ssrc 11636659 -dn -sn -vn -f rtp rtp://127.0.0.1:42509?pkt_size=400 -sdp_file pipe:4

but it doesn't change anything.

luisiam commented 1 year ago

I tried to play a tts mp3 file. I can get sound from the doorbell but it is too distorted and I cannot hear the content at all.

savage7 commented 1 year ago

I tried to play tts in homeassitant and via curl. It works basically 🥇 but there is a delay and noise.

NickM-27 commented 1 year ago

this commit seems to break rtsp restreaming for me

AlexxIT commented 1 year ago

Well. I need to remove all this changes from master version because they broke somethings. Don't know why.

Maybe someone can give me remote access to doorbell for experiments: https://github.com/AlexxIT/go2rtc/wiki/Tunnel-RTSP-camera-to-Intenet

Also I need some other camera near this doorbell, so I can know if it play backchannel.

spawn451 commented 1 year ago

RTP Wireshark trace (while using microphone) if it can help. I'm using the https://github.com/AlexxIT/go2rtc/commit/b8953e7bb57eeb37db08b5b5c2802825b0b5a377 commit because setting the Marker to true (clone.Header.Marker = true) made things worst.

GO2RTC image image

Happytime Onvif Client image image

AlexxIT commented 1 year ago

Maybe timestamp should be always zero. I don't know. @spawn451 you can try it instead of clone.Header.Marker = true

I thought Happytime Onvif Client includes mark for all packets: https://github.com/AlexxIT/go2rtc/issues/331#issuecomment-1513585484

spawn451 commented 1 year ago

Already tried with timestamp 0 still not working 🤒

spawn451 commented 1 year ago

Maybe this part is also needed (need to be done before the DECRIBE method). http://www.onvif.org/wp-content/uploads/2019/07/ONVIF_Audio_Backchannel_Client_Test_Specification_19.06.pdf (page 21&22) https://www.onvif.org/ver10/media/wsdl/media.wsdl#op.GetStreamUri image

I wrote the code for this part (to improve) using https://github.com/IOTechSystems/onvif but I don't know where to embed it in go2rtc to test. Could you help me ?

AlexxIT commented 1 year ago

Go2rtc does not implement WSDL. No other cameras needs it for two way audio

AlexxIT commented 1 year ago

@spawn451 from what software you get your screens (network trace and graphics)?

spawn451 commented 1 year ago

I mainly use Wireshark https://www.wireshark.org/. Microsoft Network Monitor 3.4 is not too bad but more limited (what is interesting is the possibility of tracing the network activity of an executable) https://www.microsoft.com/en-us/download/4865

AlexxIT commented 1 year ago

@spawn451 maybe you can send dump from wireshark (when audio works) to me. You can check my contacts in the Github prifile

spawn451 commented 1 year ago

@AlexxIT Yes sure, I send you a request on discord.

AlexxIT commented 1 year ago

If someones want, he can check support in the latest master version

savage7 commented 1 year ago

@AlexxIT just tested it with the newer firmware version v3.0.0.2017_23041200, also worked :heart: :heart: :heart: also playing an audio file worked. thank you so much for fixing this.

luisiam commented 1 year ago

If someones want, he can check support in the latest master version

Great! What audio codec I should use if I am setting up the media_player with webrtc platform in Home Assistant?

AlexxIT commented 1 year ago

audio: pcma for media_player

AlexxIT commented 1 year ago

https://github.com/AlexxIT/go2rtc/releases/tag/v1.5.0

sammyke007 commented 1 year ago

@NickM-27 , will Frigate follow with the integrated go2rtc?

NickM-27 commented 1 year ago

@sammyke007 you can run whatever version of go2rtc you want https://docs.frigate.video/configuration/advanced#custom-go2rtc-version

frigate will do a period of testing and validation before updating the default dependency to 1.5

Iceman248 commented 1 year ago

Am I missing something about how this works? I just updated to 1.5.0, but I cannot get mp3 file or 2-way audio to work? I have the v3.0.0.1859_23030900 firmware.

NickM-27 commented 1 year ago

@Iceman248 you probably need to be on the newer 0412 firmware

Iceman248 commented 1 year ago

@Iceman248 you probably need to be on the newer 0412 firmware

I heard some issues were present with it though, but I'll give it a shot. Thanks.

NickM-27 commented 1 year ago

@Iceman248 you probably need to be on the newer 0412 firmware

I heard some issues were present with it though, but I'll give it a shot. Thanks.

yes, there are issues with it that I have seen as well, of course there are no other options until reolink releases a firmware that works well. I am on the 0109 build because of this

Iceman248 commented 1 year ago

Still have nothing on the latest firmware.

sammyke007 commented 1 year ago

@NickM-27 , tnx, 1.5.0 succesfully loaded into Frigate.

Whats is your current working go2rtc config for our doorbell (on FW v3.0.0.2017_23041200)? I'm using

deurbel:
      - http://192.168.1.210/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=***&password=***
      - ffmpeg:deurbel#audio=opus
deurbel_sub:
      - http://192.168.1.210/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=***&password=***

But I guess it should be

deurbel:
      - rtsp://***:***@192.168.1.210:554/h264Preview_01_main
      - ffmpeg:deurbel#audio=opus
deurbel_sub:
      - rtsp://***:***@192.168.1.210:554/h264Preview_01_sub

Correct? Or rtsp://:@192.168.1.210:554/Preview_01_main ?

NickM-27 commented 1 year ago

if you want two way audio you of course need to use RTSP, rtsp://:@192.168.1.210:554/Preview_01_main is fine as it is the same stream as rtsp://:@192.168.1.210:554/h264Preview_01_main

Iceman248 commented 1 year ago

I forgot about it needing RTSP to work. It works now. Should I or do I need to create a separate camera for this particular stream being I only would use it for 2-way audio or should I just be adding the stream below the FLV stream I am already using?

NickM-27 commented 1 year ago

you can do either, up to you

Iceman248 commented 1 year ago

Okay, thanks. When pulling streams through go2rtc, how does it determine whether it uses the RTSP or FLV feed that it is pulling?

NickM-27 commented 1 year ago

I believe that it looks for the codecs that the consumer (RTSP, webrtc, etc) are requesting and if it can be satisfied the data is sent otherwise the next producer is check to see if it can satisfy the request.

So for RTSP restream it will use FLV and when you open a video+audio+microphone webrtc stream it will open the rtsp connection to get the backchannel audio

luisiam commented 1 year ago

Has anyone tried to setup iframe in Home Assistant? I tried both URL in the links page and none of them work. I have go2rtc setup as Home Assistant add-on.

image

Or is there any other way to make it work without exposing the go2rtc API to the internet?

quizzical86 commented 1 year ago

As this was all pretty new to me I thought I'd write down the steps I took to integrate the doorbell with 2-way audio support using go2rtc as it wasn't trivial, in the hope that it can help someone. Steps I took:

This allows me to see my camera and hear the audio from the doorbell microphone, but not speak trough the doorbell speaker. I understand this is because no current Lovelace cards support that. _The only alternative to my understanding is to install separately the go2rtc addon (instead of having WebRTC take care of it._

* In the main config folder in home assistant create "go2rtc.yaml" with the following content:

streams: reolink:

image 1: go to Access Lists 2: create a new one and name it 3: click satisfy any 4: go to authorization and choose a login and password 5: save

Then create the proxy that will enable the external access: image 1: go to Hosts and add a new proxy host 2: fill in the URL with which you want to access go2rtc and all the other settings as you see on this screen. 3: also enable the Access List you just created which requires setting a username and password 4: under SSL choose "request a new SSL certificate" and select 'force SSL'. Then Save Now you can navigate from anywhere to the URL you just created and after filling in the username and password you will reach the GO2RTC addon and also use the direct link to open the stream with two way audio. If you want to avoid having to regularly fill in the username and password then you can include this in the URL of the stream like this: https://username:password@go2rtc.yourdomain.com/webrtc.html?src=doorbellname&media=video+audio+microphone

I'm using a Home Assistant automation that opens that URL on my smartphone automatically whenever someone rings the door. It's super simple and looks like this in Node Red: image Here's the code that you can copy into Node Red. [{"id":"823df126e62785d5","type":"server-state-changed","z":"34843a6c.50d986","name":"Doorbell pressed","server":"5c29d263.09d2ac","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.reolink_video_doorbell_poe_visitor","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":1420,"y":760,"wires":[["33113cdc4d83de39"],[]]},{"id":"33113cdc4d83de39","type":"api-call-service","z":"34843a6c.50d986","name":"Launch twowaytalk on mobile","server":"5c29d263.09d2ac","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_mobile_john","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"command_activity\",\"data\":{\"intent_package_name\":\"com.android.chrome\",\"intent_action\":\"android.intent.action.VIEW\",\"intent_uri\":\"https://username:password@go2rtc.yourdomain.com/webrtc.html?src=doorbellname&media=video+audio+microphone\",\"importance\":\"high\",\"priority\":\"high\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1640,"y":760,"wires":[[]]},{"id":"5c29d263.09d2ac","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}] Also with the native Home Assistant it should be super easy.

Any insights on how to improve the issues in bold would be very welcome :)

AlexxIT commented 1 year ago

I forgot to add fix when audio starts sending only after response on play command. Maybe that's why sometimes two way audio doesn't work

NdR91 commented 1 year ago

As this was all pretty new to me I thought I'd write down the steps I took to integrate the doorbell with 2-way audio support using go2rtc as it wasn't trivial, in the hope that it can help someone. Steps I took:

  • Install WebRTC in Home Assistant using HACS (which then itself takes care of installing go2rtc) and then adding it as an integration.
  • Add a new "custom:webrtc-camera" card in the Home Assistant dashboard (aka lovelace) with the following content:
    ``` type: custom:webrtc-camera url: rtsp://[admin:password@192.168.10.5:554/h264Preview_01_sub](http://admin:password@192.168.10.5:554/h264Preview_01_sub) ```

This allows me to see my camera and hear the audio from the doorbell microphone, but not speak trough the doorbell speaker. I understand this is because no current Lovelace cards support that. The only alternative to my understanding is to install separately the go2rtc addon (instead of having WebRTC take care of it.

  • In the main config folder in home assistant create "go2rtc.yaml" with the following content:
streams:
  reolink:
    - rtsp://[admin:password@192.168.10.5:554/h264Preview_01_sub](http://admin:password@192.168.10.5:554/h264Preview_01_sub)
    - ffmpeg:reolink#audio=opus

 

  • In configuration.yaml add the following content:
media_player:
  - platform: webrtc #to set up the reolink doorbell as a media player using webrtc which supports 2-way audio. Thus I can play sounds on the camera.
    name: Deurbel
    stream: reolink
    audio: pcma

This adds the doorbell's built in speaker as a media player enabling TTS, playing MP3 files,... It doesn't work for me because I see the embedded WebRTC is v1.2.0 while I should use 1.5.0

  • For the 2 reasons in italics above I then proceeded to install the go2rtc in Home Assistant.
  • go2rtc didn't want to start (the log remained empty) so I removed the WebRTC integration, then removed WebRTC from HACS as well. After a reboot of Home Assistant I saw that in the folder /config the file "go2rtc-1.2.0" was still present so I deleted that.
  • Now the go2rtc addon was willing to start. It picked up the "go2rtc.yaml" settings correctly. Clicking the stream link allowed me to see video from the doorbell camera and hear audio from it's microphone. However it didn't give a possibility to use the doorbell speaker or ask to activate my phone's microphone.
  • In the "links" section at the bottom I could click "video+audio+microphone = two way audio from camera" and then the webrtc.html link. This time it did ask for access to my phone's microphone but it never loaded the video stream or audio
  • I then proceed to open port 8555 (UDP and TCP) in my router and forward it to my Home Assistant IP.
  • Now it works and my voice can be heard trough the doorbell speaker, after close to 10 seconds of loading. Any tips on how to speed this up or to have the sound unmuted by default (currently I have to manually tap a button to unmute the sound coming from the doorbell)?
  • I then reinstalled WebRTC through HACS and as an integration. Playing media files: This seems to work more or less. It sometimes plays the mp3 file and sometimes doesnt and it doesn't play the full file (the moment it stops playing differs from file to file, but for each individual file it is always at the same moment). TTS: Doesn't work.

Any insights on how to improve the issues in bold would be very welcome :)

Did you find a solution?

Thanks!

quizzical86 commented 1 year ago

I'm not sure which of my issues in bold you are referring to, but the answer is no :) As you can see above, AlexxIT reopened this issue to improve some two way audio playback issues

Cyclone47 commented 1 year ago

As this was all pretty new to me I thought I'd write down the steps I took to integrate the doorbell with 2-way audio support using go2rtc as it wasn't trivial, in the hope that it can help someone. Steps I took:

  • Install WebRTC in Home Assistant using HACS (which then itself takes care of installing go2rtc) and then adding it as an integration.
  • Add a new "custom:webrtc-camera" card in the Home Assistant dashboard (aka lovelace) with the following content:
type: custom:webrtc-camera
url: rtsp://[admin:password@192.168.10.5:554/h264Preview_01_sub](http://admin:password@192.168.10.5:554/h264Preview_01_sub)

This allows me to see my camera and hear the audio from the doorbell microphone, but not speak trough the doorbell speaker. I understand this is because no current Lovelace cards support that. The only alternative to my understanding is to install separately the go2rtc addon (instead of having WebRTC take care of it.

  • In the main config folder in home assistant create "go2rtc.yaml" with the following content:
streams:
  reolink:
    - rtsp://[admin:password@192.168.10.5:554/h264Preview_01_sub](http://admin:password@192.168.10.5:554/h264Preview_01_sub)
    - ffmpeg:reolink#audio=opus

 

  • In configuration.yaml add the following content:
media_player:
  - platform: webrtc #to set up the reolink doorbell as a media player using webrtc which supports 2-way audio. Thus I can play sounds on the camera.
    name: Deurbel
    stream: reolink
    audio: pcma

This adds the doorbell's built in speaker as a media player enabling TTS, playing MP3 files,... It doesn't work for me because I see the embedded WebRTC is v1.2.0 while I should use 1.5.0

  • For the 2 reasons in italics above I then proceeded to install the go2rtc in Home Assistant.
  • go2rtc didn't want to start (the log remained empty) so I removed the WebRTC integration, then removed WebRTC from HACS as well. After a reboot of Home Assistant I saw that in the folder /config the file "go2rtc-1.2.0" was still present so I deleted that.
  • Now the go2rtc addon was willing to start. It picked up the "go2rtc.yaml" settings correctly. Clicking the stream link allowed me to see video from the doorbell camera and hear audio from it's microphone. However it didn't give a possibility to use the doorbell speaker or ask to activate my phone's microphone.
  • In the "links" section at the bottom I could click "video+audio+microphone = two way audio from camera" and then the webrtc.html link. This time it did ask for access to my phone's microphone but it never loaded the video stream or audio
  • I then proceed to open port 8555 (UDP and TCP) in my router and forward it to my Home Assistant IP.
  • Now it works and my voice can be heard trough the doorbell speaker, after close to 10 seconds of loading. Any tips on how to speed this up or to have the sound unmuted by default (currently I have to manually tap a button to unmute the sound coming from the doorbell)?
  • I then reinstalled WebRTC through HACS and as an integration. Playing media files: This seems to work more or less. It sometimes plays the mp3 file and sometimes doesnt and it doesn't play the full file (the moment it stops playing differs from file to file, but for each individual file it is always at the same moment). TTS: Doesn't work most of the time and when it does work it only plays part of the text.

Any insights on how to improve the issues in bold would be very welcome :)

Is the formatting of your URL like this on purpose? For me I get errors that it's incorrect when using it like this

type: custom:webrtc-camera url: rtsp://[admin:password@192.168.10.5:554/h264Preview_01_sub](http://admin:password@192.168.10.5:554/h264Preview_01_sub) It gives an error; did github break your syntax or are you purposely adding the http url behind it in brackets? image

Doing it like this works, but I guess it won't work then? rtsp://admin:password@192.168.10.5:554/h264Preview_01_sub

quizzical86 commented 1 year ago

Thanks for flagging. Indeed Github broke the syntax. I have been updating that post based on the further testing I am doing. I corrected the syntax now.

In short:

Daniel-dev22 commented 1 year ago

Has anyone tried the latest reolink firmware with 2 way talk a new version was released yesterday.

quizzical86 commented 1 year ago

I will read first a bit about the experiences on this forum before upgrading: https://community.reolink.com/topic/5430/doorbell-first-new-firmware-support-more-smart-home-features-onvif-with-two-way-audio/31?post_id=21213&page=2

I have little faith in the Reolink firmware upgrades.

quizzical86 commented 1 year ago

@AlexxIT I have created an automation in my Home Assistant to open the two-way-audio URL in the Chrome browsers on my smartphone when someone rings the door.

automation:
  - alias: DoorbellSpeak
    trigger:
      ...
    action:
      - service: notify.mobile_app_<your_device_id_here>
        data:
          message: "command_activity"
          data:
            intent_package_name: "com.android.chrome"
            intent_action: "android.intent.action.VIEW"
            intent_uri: "https://linktomyhomeassistant.com/api/hassio_ingress/allkindsofnumbersandletters/webrtc.html?src=reolink&media

But generally I get the error page "401: Unauthorized". If in Chrome I go to my homeassistant url, then to the go2rtc page, then to links, then select "video+audio+microphone = two way audio from camera" and then click webrtc.html it does tend to work while it's exactly the same URL. Anything I can do to be able to open that link directly without having to go trough all those steps?

AlexxIT commented 1 year ago

You can't use /hassio_ingress/ urls outside Hass web page. Because you will get... Unauthorized error.

tipofthesowrd commented 1 year ago

I got it working using frigate including talking back.

This also works in the HA companion app and my chromium browser. All traffic is running through nginx proxy with Let's Encrypt SSL for local & remote connections.

~The only issue I'm facing is that when testing with my Home Assistant companion app via mobile connection I'm not getting the frigate lovelace microphone button.~ Found the solution connection via mobile was running via ipv6 and not reaching the needed port forward for webrtc

edit: for audio on RTC stream don't forget

go2rtc:
  streams:
    deurbel:
      - rtsp://username:password@ip_address:554/h264Preview_01_sub
      - ffmpeg:deurbel#audio=opus
quizzical86 commented 1 year ago

You can't use /hassio_ingress/ urls outside Hass web page. Because you will get... Unauthorized error.

Thanks @AlexxIT! So is there a way to be able to launch a 2-way-audio stream without first having to go to the go2rtc page in Home Assistant, then click the links button, then select "video+audio+microphone = two way audio from camera" and finally click "webrtc.html"?

I think it would be really useful if – whenever someone rings the door – I could have Home Assistant send a command to my phone so that it opens a URL that loads the 2-way-audio stream so I can start talking.

Cyclone47 commented 1 year ago

You can't use /hassio_ingress/ urls outside Hass web page. Because you will get... Unauthorized error.

Thanks @AlexxIT! So is there a way to be able to launch a 2-way-audio stream without first having to go to the go2rtc page in Home Assistant, then click the links button, then select "video+audio+microphone = two way audio from camera" and finally click "webrtc.html"?

I think it would be really useful if – whenever someone rings the door – I could have Home Assistant send a command to my phone so that it opens a URL that loads the 2-way-audio stream so I can start talking.

I am also curious about this! In my case I wanted to push a mp3 to the doorbell using POST. However, I could only get it to work by opening the html page and typing in ffmpeg:http://192.168.xxx.xxx:8123/local/recording.mp3#audio=pcma#input=file

I've tried capturing the full URL using network console, but using it as full URL doesn't work. http://192.168.xxx.xxx:1984/streams?dst=reolink&src=ffmpeg:http://192.168.xxx.xxx:8123/local/recording.mp3#audio=pcma#input=file