Realtime camera streaming without any delay - WebRTC

Isn’t that really just this:

And this was wrong anyway? are you really just creating a second stream with the same audio codec.

- ffmpeg:rtsp://localhost:8554/camera.terrass?audio=copy

I dont know much about those config settings but as soon as I add #video=copy#audio=copy#audio=opus to the end it uses MSE instead of RTC and I’m back to 2.5 seconds or something

I hate to claim defeat… can I please ask for some help.

Problem: No video, audio only

Some facts:

  • I have WebRTC-Camera integration installed with go2rtc.
  • I have the rtsp stream URL
  • I have the rtsp stream playing directly with VLC
  • When I use WebRTC I get audio only and no video
  • Camera brand is Dorani (Australian no-name brand, unsure of the OEM)
  • I have tried changing the video compression on the camera from h265 to h264 and my result appears the same
  • I have tried chrome and safari
  • The “Generic-Camera” integration is displaying the rtsp stream fine, albeit a 8 to 10 second delay which has brought me to WebRTC

The Camera configuration looks like this:

My go2rtc config looks like this:

log:
    level: debug

streams:
    camera.driveway:
        url: rtsp://user:pass@@192.168.4.244:554/unicast/c1/s0/live

The “MSE” stream has near real-time audio but a blank video
The “WebRTC” stream sits there loading with a blank screen and no audio

When I look at the go2rtc logs I see errors like this:

06:20:12.727 WRN [rtsp] error="streams: codecs not matched: PCMU => H264, H265, AAC" stream=camera.driveway
06:20:43.981 DBG [rtsp] new consumer stream=camera.driveway
06:20:43.984 WRN [rtsp] error="streams: codecs not matched: PCMU => H264, H265, AAC" stream=camera.driveway
08:47:16.774 DBG [webrtc] new consumer src=camera.driveway
08:47:35.743 DBG [webrtc] new consumer src=camera.driveway
08:48:54.460 DBG [webrtc] new consumer src=camera.driveway

My reading indicates I’ve got codec issues but I am unsure how to solve from here and I feel I am just trying random configs without any real progress.

Try this:

streams:
    camera.driveway:
        - ffmpeg:{input}#video=copy#audio=aac#audio=copy

Or

streams:
    camera.driveway:
        - {input}
        - ffmpeg:{input}#audio=aac

And btw doesn’t your home assistant camera already have the rtsp feed defined? If so, that’s why I put {input} in the configs above.

Typically I set up the camera completely in go2rtc and then point the ha camera to go2rtc instead. But you can do it the other way.

This is the way I would have done it though:

streams:
    driveway:
        - rtsp://user:pass@@192.168.4.244:554/unicast/c1/s0/live
        - ffmpeg:{input}#audio=aac

Then in the ha camera you’d point to that camera something like this:

rtsp://127.0.0.1:8554/driveway
1 Like

Start from checking stream info for active stream from WebUI

1 Like

Thanks to both of you.

Couldn’t get h265, but after reseting the IPC’s to h264 and rebooting both the NVR and IPC’s, it seems to have started to work with an “MSE” stream.

I also moved go2rtc to a docker container rather than in the HASOS VM to get better performance as the HASOS integration of go2rtc in the VM resulted in slow choppy video with real-time audio

Now, do I want to stay with MSE or should I continue to tinker to get RTC or something else?

Hi @AlexxIT,

Great addon you’ve made there.
I managed to get my camera connected over WebRTC without any issues.
But I was wondering if I can use the WebRTC stream outside of HomeAssistant as well?

I’m building a stand alone dashboard for my home assistant which connects to HomeAssistant using websockets & the RestAPI to exchange the needed information and call the desired services.

Now I was wondering if I can implement my WebRTC stream directly into my Nuxt3 app?
Great stuff, thanks!

Pieter

I think you haven’t read docs carefully. About go2rtc and separate WebUI.

Hi @AlexxIT,
Quick question i hope!

How do I update the version of go2RTC that is already embedded in FRIGATE (0.12.1-367d724)

Currently i have Go2rtc version 1.6.2 embedded as part of Frigate 0.12.1 and since i want to use the homekit witht the new go2rtc i was learned that i need to upgrade it to 1.7.

Can you please explain how can i update this ?

Answer in the Frigate docs

1 Like

I tried to look it around already didnt find it.
can you point me, please

Found it :slight_smile: thank you!

@AlexxIT Thank you,
small update in my question, i was able to add all cameras to the new web2rtc and all of them have sound!
image

My only concern now is how to expose them to homekit. I have one camera that was configured in firgate.yaml → under “cameras:” and “go2rtc:” → ffmpeg inputs:
and I was able to expose this to Homekit, which is nice because it displays the detect on my TV. However, it is using a lot of resources, which I assume is a result of the frigate. Is it possible to get the same feature (TV detection) via Homekit and Go2RTC alone? If not, how can I improve this so that I can add 8 cameras?

I also tried to install rtcptowebrtc - here all works well but only the sound it not working ( my guess is that i need to configure it somewhere and again dont know where?) → but you cant expose this outside … limitation on the rtcptoweb

So only go2rtc option is left…

Config example a Manual Lovelace Card for Mobotix S15:

type: custom:webrtc-camera
url: rtsp://USERNAME:YOURSECRET@IP:554/stream3/mobotix.mjpeg
media: video,audio
ui: true
digital_ptz:
  mouse_drag_pan: true
  mouse_wheel_zoom: true
  mouse_double_click_zoom: true
  touch_drag_pan: true
  touch_pinch_zoom: true
  touch_tap_drag_zoom: true
  persist: true

And Mobotix M16:

type: custom:webrtc-camera
url: rtsp://USERNAME:YOURSECRET@IP:554/mobotix.h264
ui: true
digital_ptz:
  mouse_drag_pan: true
  mouse_wheel_zoom: true
  mouse_double_click_zoom: true
  touch_drag_pan: true
  touch_pinch_zoom: true
  touch_tap_drag_zoom: true
  persist: true

Great Tool. Finally, I can see a fluent video stream in dashboards. Thank you!

1 Like

Recently noticed an error in chrome logs:

load_resource.ts:32
GET http://*REDACTEDIP:PORT/webrtc/webrtc-camera.js net::ERR_ABORTED 404 (Not Found)

/webrtc/webrtc-camera.js is set in my resources

If I manually copy over the www folder from webrtc to community plugins folder and use /hacsfiles/webrtc/webrtc-camera.js it works fine, seems it cannot access /webrtc?

Can someone help?..

Why are you making up links out of your head rather than using the ones written in the documentation?

PS. If you didn’t use lovelace mode yaml - everything would work automatically without manual editing of links.

PS. This component not using www folder, this component not using hacsfiles folder, this component is not HACS frontend project.

I only “made up links” to test as following the documentation doesn’t work…

So you haven’t setup integration. Or it can’t start for providing that link for some reason.

If you sure that you setup integration and you receiving 404 for this link - check errors log.

You need to install the integration to setup the files and lovelace card.

I want to change the layout of the webrtc card a bit. Is it possible to apply multiple style instructions?

I tried

style:
  - '.header {display: none}'
  - '.pictureinpicture {display: none}'

But only the first one is accepted in this case. What is the correct syntax, assuming its possible to combine?

I have the issue that from time to time (sometimes within 5 minutes, sometimes within 20 minutes) my stream just stops - the picture doesn’t change anymore.

go2rtc log says nothing and HA says:

Log details (ERROR)

Logger: homeassistant.components.stream.stream.camera.10_0_0_156
Source: components/stream/init.py:431
Integration: Stream (documentation, issues)
First occurred: 10:22:15 (59 occurrences)
Last logged: 13:36:09

  • Error from stream worker: Stream ended; no additional packets
  • Error from stream worker: Error opening stream (ERRORTYPE_113, Host is unreachable) rtsp://:@10.0.0.156:8554/Streaming/Channels/101