Currently trying to just get one way working without audio, but struggling. I have 2 x AD410 and 1 Hikvision (don’t remember model, but its an older cube). Currently have Camera → Frigate → Frigate Integration in HA. Go2RTC is setup as an addon, and RTSPtoWebRTC running as an integration. The cameras are being used as camera. which is created by the Frigate Integration. The two AD410 camera’s work just fine, but the Hikvision keeps failing. I a little blip of the screen and then get “couldn’t find the matching tracks”… Any suggestions where to look?
I installed Go2RTC in HA and I created a go2rtc.yaml
file in my config file and added streams and I have HTTPS setup with my configuration. I can see the video with the webrtc link in the Web UI but no audio. I can’t see video with the RTSP link. It prompts me to open another app. I am confused about what I need to do to get audio. I have read over the Github page and this thread multiple times but I am not sure which other setting I need to get audio.
This is what is in my yaml
rtsp:
listen: ":8554"
streams:
AD410:
- rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
- rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=1
This is what is says in info in the Web UI
[
{
"media:0": "video, sendonly, 96 H264/90000",
"media:1": "audio, sendonly, 97 MPEG4-GENERIC/8000",
"receive": 47849375,
"remote_addr": "192.x.x.x:554",
"send": 0,
"track:0": "96 H264/90000, sinks=1",
"type": "RTSP client producer",
"url": "rtsp://192.x.x.x:554/cam/realmonitor?channel=1\u0026subtype=1/"
},
{
"remote_addr": "",
"send": 48232550,
"type": "MP4 server consumer",
"user_agent": ""
}
]
Do I need to change the streams or subtypes? Do I need to add or remove something in the yaml? Do I need to configure something in my router or something else in HA?
The answer is at the beginning of the documentation.
WebRTC does not support the AAC (MPEG4) codec.
What do I need to do to get two way audio with the Amcrest AD410 like calisro stated he can? Isn’t RTSP supposed to be an option?
I just received my new IMOU Rex camera. Wanted to add it to my yaml file.
I have added the following:
camfynn_camera: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
Now this works fine for the MSC stream and MP4 stream, but doesn’t for webRTC. The stream just won’t start.
any thoughts?
Check what codecs it uses. You may need to transcode or change them. You can check the logs and also could increase the debug verbosity.
i’m using:
log:
level: info # default level
api: debug
rtsp: debug
streams: debug
webrtc: debug
the logs show:
05:35:49.564 WRN [api.webrtc] add consumer error=“couldn’t find the matching tracks”
So I guess that supports the statement it uses a different codec. I’ll try and do some more reading.
For me, what I can’t explain is that profile001 works fine, but is 4:3 ratio, profile000 which is 16:9, like it should, doesn’t.
Can it have to do with the stream being encoded in h.265 instead of h.264. It’s what I’m reading on a few places and I should be able to change it but I can’t for some reason.
Managed to get the config tool working, changed encoding to 264 and worked instantly.
@AlexxIT, any sense of when the WebRTC camera custom card will be updated to use go2rtc? Curious on how that will work compared to the RTSPtoWebRTC integration or the iframe methods of using go2rtc. I have tried both. Using the RTSPtoWebRTC integration method is the most reliable, although I still get the “timeout handling WebRTC offer” error from time to time. The iframes method works ok, but every so often a camera (not the same one every time) will just refuse to load up, which also happens when accessing it via the addon web ui.
Honestly the frigate card is great (I don’t use frigate itself, just the card). There’s also some work being done there to make 2 way audio work… Just fyi.
@AlexxIT Any idea why this won’t work:
streams:
backyard:
- rtsp://admin:[email protected]/h264Preview_01_main
testing:
- rtsp://127.0.0.1:8554/backyard
- ffmpeg:rtsp://127.0.0.1:8554/backyard#audio=opus
But this will:
streams:
backyard:
- rtsp://admin:[email protected]/h264Preview_01_main
testing:
- ffmpeg:rtsp://127.0.0.1:8554/backyard#video=copy#audio=opus
When I try to ONLY capture audio using ffmpeg like the first example, I get errors like this. But if I add ‘copy’ it will work:
20:25:34.955 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:104 > error=EOF
20:25:34.955 DBG [streams] reconnect to url=ffmpeg:rtsp://127.0.0.1:8554/backyard#audio=opus
20:25:34.956 DBG [exec] run url="exec:ffmpeg -hide_banner -allowed_media_types audio -fflags nobuffer -flags low_delay -rtsp_transport tcp -timeout 5000000 -i rtsp://127.0.0.1:8554/backyard -af \"volume=10dB\" -c:a libopus -b:a 16K -vbr constrained -vn -rtsp_transport tcp -f rtsp rtsp://localhost:8554/101446d7deb6a801a0e4f832aa198a6f"
20:25:34.957 DBG github.com/AlexxIT/go2rtc/cmd/rtsp/rtsp.go:196 > error=EOF
20:25:34.957 DBG [rtsp] disconnect stream=backyard
20:25:35.019 ERR [api.ws] readJSON error="websocket: close 1000 (normal)"
However, if I don’t use loopback, it’ll work just fine like this:
streams:
testing:
- rtsp://admin:[email protected]/h264Preview_01_main
- ffmpeg:rtsp://[email protected]/h264Preview_01_main#audio=opus
Thanks @calisro, how did you add the cameras to the frigate card? Did you just point it to the RTSP link from go2rtc or are you using RTSPtoWebRTC integration? And which provider did you pick for your live view? Any chance you could share your yaml for the card so I can reverse engineer it? Thanks as always.
I am using the RTSPtoWebRTC. I am using decluttering templates so i’ll paste the portions but you’ll need to reconstruct them to a regular yaml if you’re not using that…
cameras is the base template and I included my more complex front door camera and a very basic backyard camera.
If you have any questions, feel free to ask. The frigate card has so many options… It’s really well done. I am looking forward to replacing my iframe with 2-way audio when that happens.
decluttering_templates:
cameras:
default:
- elements: []
- view: image
- refresh_seconds: 3
- cameras: []
- aspect_ratio: '4:3'
- auto_unmute: never
card:
type: custom:frigate-card
cameras: '[[cameras]]'
view:
default: '[[view]]'
camera_select: live
dimensions:
aspect_ratio: '[[aspect_ratio]]'
aspect_ratio_mode: static
image:
mode: camera
refresh_seconds: '[[refresh_seconds]]'
timeout_seconds: 3
actions:
tap_action:
action: custom:frigate-card-action
frigate_card_action: live
hold_action:
action: navigate
navigation_path: '[[subcard]]'
live:
controls:
title:
mode: none
next_previous:
size: 26
lazy_unload: hidden
auto_play: selected
auto_mute: all
auto_unmute: '[[auto_unmute]]'
auto_pause: all
draggable: false
layout:
fit: fill
actions:
tap_action:
action: custom:frigate-card-action
frigate_card_action: image
hold_action:
action: navigate
navigation_path: '[[subcard]]'
menu:
buttons:
live:
enabled: true
image:
enabled: true
frigate:
enabled: false
cameras:
enabled: false
media_player:
enabled: false
style: outside
alignment: right
position: top
button_size: 26
elements: '[[elements]]'
camera_front_door:
defailt:
view: image
card:
type: custom:decluttering-card
template: cameras
variables:
- subcard: /my-home/doorbell-camera
- view: '[[view]]'
- entity_id: camera.front_door_main
- refresh_seconds: 3
- cameras:
- camera_entity: camera.front_door_main
triggers:
entities:
- binary_sensor.front_door_bell_human
- binary_sensor.front_door_bell_motion
- binary_sensor.front_door_bell_ring
motion: false
occupancy: false
- camera_entity: camera.front_door_last_event
triggers:
entities:
- binary_sensor.front_door_bell_human
- binary_sensor.front_door_bell_motion
- binary_sensor.front_door_bell_ring
motion: false
occupancy: false
- elements:
- type: custom:frigate-card-menu-icon
icon: mdi:view-gallery
title: Gallery
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: Front Door Gallery
size: wide
content:
type: vertical-stack
cards:
- type: custom:gallery-card
title: Front Door History
show_reload: true
entities:
- sensor.frontdoor
maximum_files: '100'
file_name_format: doorbell_%YYY%m%d-%H%M%S
caption_format: '%m/%d %H:%M%p'
caption_leading_zeros: false
menu_alignment: Bottom
parsed_date_sort: true
- type: custom:frigate-card-menu-icon
icon: mdi:phone-forward
title: Talk
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: Frontdoor Call
size: wide
content:
type: iframe
url: /go2rtc/webrtc.html?src=frontdoor_call
aspect_ratio: 75%
right_button: Unlock Door
right_button_action:
service: lock.unlock
data:
entity_id: lock.front_door
left_button: Lock Door
left_button_action:
service: lock.lock
data:
entity_id: lock.front_door
- type: custom:frigate-card-menu-icon
icon: mdi:microphone-message
title: Door Actions
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: Door Actions
size: normal
content:
type: entities
entities:
- entity: input_select.tts_door_text_selection
- entity: input_text.tts_door_text
- entity: lock.front_door
tap_action:
action: toggle
- type: custom:frigate-card-menu-state-icon
entity: lock.front_door
title: Frontdoor Lock
tap_action:
action: toggle
camera_backyard:
default:
view: image
card:
type: custom:decluttering-card
template: cameras
variables:
- subcard: /my-home/backyard-camera
- view: '[[view]]'
- entity_id: camera.backyard_main
- cameras:
- camera_entity: camera.backyard_main
- elements:
- type: custom:frigate-card-menu-state-icon
entity: switch.backyard_landscaping
title: Landscape Lights
tap_action:
action: toggle
- type: custom:frigate-card-menu-state-icon
entity: switch.backyard_flood_lights_2
title: Flood Lights
tap_action:
action: toggle
- type: custom:frigate-card-menu-state-icon
entity: group.backyard_presense
title: Pool
icon: mdi:pool
tap_action:
action: navigate
navigation_path: /my-home/pool
These are the regular views:
- theme: Backend-selected
title: Backyard Camera
subview: true
path: backyard-camera
type: panel
icon: mdi:pool
badges: []
cards:
- type: vertical-stack
cards:
- type: custom:template-entity-row
name: Home
icon: mdi:home
tap_action:
action: navigate
navigation_path: /my-home/navigate
- type: custom:decluttering-card
template: camera_backyard
variables:
- view: live
- theme: Backend-selected
title: Doorbell Camera
subview: true
path: doorbell-camera
type: panel
icon: mdi:doorbell-video
badges: []
cards:
- type: vertical-stack
cards:
- type: custom:template-entity-row
name: Home
icon: mdi:home
tap_action:
action: navigate
navigation_path: /my-home/navigate
- type: custom:decluttering-card
template: camera_front_door
variables:
- view: image
Thanks so much! I’ll give it a try and let you know how it goes. Although interestingly enough the iframes have actually been working pretty well for the past two days. Go figure.
What’s nice about the card is… I have a cluster of 6 Cameras. When one doesn’t load I can simply click the live button to reload that one camera rather than refreshing and trying to reload them all. Among other features of course
With the frigate card you are referring to: GitHub - dermotduffy/frigate-hass-card: A Lovelace card for Frigate in Home Assistant ?
Yes that’s it. It’s in HACS
I am 80% of the way to getting this working with my AD410. I have the stream configured in go2rtc running as an addon, i have the WebRTC integration configured, I have a generic camera setup in HA pointing at the rtsp stream from go2rtc, i have the stream viewable in a card on a dashboard with audio coming FROM the doorbell to whatever device is viewing the dashboard as long as i am internal. I cant get 2-way audio working at all, and if i am on my phone running on cell data the card does not load right. I have a few questions:
Do i need to configure the stream to be accessible from an https url? If so how would i go about doing that safely?
I use traefik and the cloudflare tunnel running as dockers on another machine with Authelia in the middle for my remote access solution, is that an issue?
Do i need to use the frigate card? I have it downloaded, i am just assuming that once i solve the https issue it will just start working.
Here is my config file for go2rtc:
log:
level: info # default level
api: debug
rtsp: debug
streams: debug
webrtc: debug
api:
listen: ":1984"
rtsp:
listen: ":8554"
streams:
AD410_go2rtc:
- rtsp://<Username:Password@IP>:554/cam/realmonitor?channel=1&subtype=0&unicast=true
Here are the logs:
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
05:23:58.052 INF [api] listen addr=:1984
05:23:58.052 INF [rtsp] listen addr=:8554
05:23:58.053 INF [hass] load stream url=hass:127_0_0_1
05:23:58.053 INF [srtp] listen addr=:8443
05:25:37.329 DBG [rtsp] new consumer stream=AD410_go2rtc
05:25:37.329 DBG [streams] probe producer url=rtsp://<Username:Password@IP>:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
05:25:37.588 DBG [streams] start producer url=rtsp://<Username:Password@IP>:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
05:25:57.329 DBG github.com/AlexxIT/go2rtc/cmd/rtsp/rtsp.go:196 > error=EOF
05:25:57.329 DBG [streams] stop producer url=rtsp://<Username:Password@IP>:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
05:25:57.329 DBG [rtsp] disconnect stream=AD410_go2rtc
05:26:00.216 DBG [rtsp] new consumer stream=AD410_go2rtc
05:26:00.216 DBG [streams] probe producer url=rtsp://<Username:Password@IP>:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
05:26:00.395 DBG [streams] start producer url=rtsp://<Username:Password@IP>:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
05:26:08.896 DBG [rtsp] new consumer stream=AD410_go2rtc
05:26:27.369 DBG [rtsp] new consumer stream=AD410_go2rtc
I set the codec for the AD410 to G.711A using the Amcrest software as well. Here is the information from go2rtc:
[
{
"media:0": "video, sendonly, 96 H264/90000",
"media:1": "audio, sendonly, 8 PCMA/8000",
"media:2": "audio, recvonly, 8 PCMA/8000",
"receive": 46190299,
"remote_addr": "<IP>:554",
"send": 0,
"track:0": "8 PCMA/8000, sinks=5",
"type": "RTSP client producer",
"url": "rtsp://<IP>:554/cam/realmonitor?channel=1\u0026subtype=0\u0026unicast=true/"
},
{
"media:0": "video, recvonly, 96 H264/90000",
"media:1": "audio, recvonly, 97 PCMA/8000",
"receive": 0,
"remote_addr": "127.0.0.1:45706",
"send": 15411485,
"track:0": "97 PCMA/8000, sinks=5",
"type": "RTSP server consumer",
"url": "rtsp://127.0.0.1:8554/AD410_go2rtc",
"user_agent": "Lavf59.16.100"
},
{
"remote_addr": "udp4 host 10.0.100.100:63541",
"send": 15274869,
"type": "WebRTC server consumer",
"user_agent": "HomeAssistant/2022.10.5 aiohttp/3.8.1 Python/3.10"
},
{
"remote_addr": "udp4 prflx 10.0.100.100:51004 related :0",
"send": 7624251,
"type": "WebRTC server consumer",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
},
{
"remote_addr": "udp4 prflx 10.0.100.100:64698 related :0",
"send": 5870617,
"type": "WebRTC server consumer",
"user_agent": "HomeAssistant/2022.10.5 aiohttp/3.8.1 Python/3.10"
},
{
"remote_addr": "udp4 host 10.0.100.100:60625",
"send": 3822026,
"type": "WebRTC server consumer",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
}
]
Any help would be appreciated.
Unfortunately until there is a card that is compatible with 2-way audio, you’ll need to expose it on https directly because we must use a iframe card pointing to the go2rtc api pages in home assistant (which won’t use the ingress feature of home assistant from the iframe). The way I’ve done this is through a port forward to nginx which proxies to home assistant with something like this to prevent all my other cameras from also being exposed in the process… I’m also behind cloudflare proxy but that’s not necessary. Just another layer of security obscurity.
Nginx example:
if ($request_uri = "/go2rtc/webrtc.html?src=frontdoor_call") {
rewrite /go2rtc/(.*) /$1 break;
}
if ($request_uri = "/go2rtc/api/ws?src=frontdoor_call") {
rewrite /go2rtc/(.*) /$1 break;
}
Lovelace:
type: iframe
url: /go2rtc/webrtc.html?src=frontdoor_call
There’s work being done in the frigate card to enable 2way which hopefully will negate all of this.
Edit: fyi whenever you view that camera it’ll disable the doorbell… Just so you know. Unless you add the go2rtc filter to disable the back channel which means you’ll probably end up with two go2rtc entries… One with backchannel to talk and one without to only view.
There’s also this:
Which I haven’t tried but the companion app works under webview so this I think would only help in a browser.
For anyone trying to do this. I missed a small thing in the example provided here:
You need the “?audio=copy”:
ffmpeg:rtsp://localhost:8554/backyard?audio=copy#audio=opus
Figured i’d answer my own question here so others maybe can use this.
This really should go in the docs.