Blog icon indicating copy to clipboard operation
Blog copied to clipboard

go2rtc is built in Home Assistant 2024.11

Open AlexxIT opened this issue 1 year ago • 36 comments

go2rtc is now built into Home Assistant starting from version 2024.11. This will allow users to view real time stream from their cameras without any additional configuration, using WebRTC technology.

Even though there was no mention of the go2rtc project in the release notes, the interest of GitHub users has increased a lot these days. The project has been on GitHub's top trending page for a few days. In Golang trends, it was ranked number one 5 days in a row.

AlexxIT%2Fgo2rtc | Trendshift

All of this got my account into the top 1000 GitHub users (based on stars count) faster than I expected. Thanks to all the users of all my projects for this.

AlexxIT

Do I need to remove the go2rtc addon or the custom WebRTC integration?

Probably the most frequent question from people who have been using WebRTC in Home Assistant for a long time. The answer depends on the features you are using.

In the most basic version of viewing the stream from cameras - additional addon or custom integration are no longer needed. But when are they needed?

Reducing the number of connections to the camera

If you have a good camera, such as a $100 Dahua, it can usually handle multiple connections without any problems.

But if you have a simple, cheap camera, like a $10 TP-Link, it can handle one, maximum two connections. Some models can handle more. If the Wi-Fi connection is not reliable - the second connection may have packet losses. If you have enabled video recording on the card or motion detection on the camera - the load on the camera also increases.

A good solution is to use the go2rtc addon where you set up one connection to that camera. And in all other software where you need a stream - use this single connection.

go2rtc will open the connection when the first client arrives and close the connection when the last client leaves.

Using advanced sources

go2rtc is not only about RTSP cameras. It supports many formats and some of them exclusively. For example, HomeKit cameras, Roborok vacuum cleaners, USB cameras, DVRIP protocol, Bubble, Kasa, and others.

Using MSE

The custom card, in addition to WebRTC technology, also is able to use MSE. This technology supports codecs that WebRTC technology does not yet support. For example, H265 and AAC. And this technology also does a better job with external connectivity to your Home Assistant, in case there are any problems connecting via WebRTC. Nabu Casa users should not worry about this problem, because the paid subscription includes access to the TURN server. One more reason for supporting the Home Assistant core team.

Using two way audio

The custom card supports two way audio if the camera supports it.

Playing TTS on two way cameras

Yes, the custom card supports this as well.

go2rtc in venv installation

go2rtc is only built in Docker versions of Home Assistant (including Supervised and OS). It's not in the regular python version. In this case, you can use go2rtc built into the custom integration. This works even in the windows - HassWP.

Conclusion

There are other addon or custom card features that you may be interested in. It is better to explore the documentation.

This was just the first release of Home Assistant with go2rtc built in. There will probably be more and more features in new versions. I know there is work in progress to support two way audio out of the box.

Hopefully, with our combined efforts, Home Assistant users will have the best experience viewing real time video from their cameras.

AlexxIT avatar Nov 13 '24 17:11 AlexxIT

@AlexxIT, this is amazing. I have been closely following your hard work at go2rtc and I'm really happy about your achievements. All the best for you!

felipecrs avatar Nov 13 '24 18:11 felipecrs

@AlexxIT amazing work, thank you! Do you have any guidance on fixing the dashcast setup now it's natively supported? I loved my camera feed auto casting when detects someone

alexanderdominicnesbitt avatar Nov 15 '24 08:11 alexanderdominicnesbitt

DashCast (casting any webpage) not supported in HA out of box. You can use it only via custom integration - WebRTC or DashCast.

AlexxIT avatar Nov 15 '24 09:11 AlexxIT

DashCast (casting any webpage) not supported in HA out of box. You can use it only via custom integration - WebRTC or DashCast.

Thanks for the reply. Now the Nabu casa (I have a sub) are running the WebRTC server, I assume I point the WebRTC camera config to their servers instead of to the addon config? Anyideas what the Nabu casa server address is?

image

image

alexanderdominicnesbitt avatar Nov 15 '24 10:11 alexanderdominicnesbitt

Newbie using only native HA (no custom cards, addOns, Integrations) regarding the 2024.11 feature "WebRTC". Have a couple of questions for clarity:

  1. This documentation uses the terms: "RTSPtoWeb{RTC} server" and "RTSPtoWeb{RTC} proxy server". a) As for "server", do these two terms mean the same thing? b) Is go2rtc the implementation of a RTSPtoWeb{RTC} server/proxy-server? Or are they different things?

  2. There is a statement in this same document on limitations of RTSPtoWeb and RTSPtoWebRTC. a) What is the difference between RTSPtoWeb and RTSPtoWebRTC? b) How do they apply to Native HA situation (i.e. no customs)?
    My confusion is that the limitations referenced in the document point to differing github repositories (from deepch), yet my thinking is that limitations should apply to the native version of HA's go2rtc which has its own repository (from AlexxIT).

tommyjlong avatar Nov 15 '24 21:11 tommyjlong

@tommyjlong, nevermind RTSPToWebRTC. They are separate integrations not related to go2rtc (even though go2rtc can act as a RTSPToWebRTC server). They are also not used by HA unless you explicitly enable them. Personally I believe this integration will be deprecated.

You should refer to:

https://www.home-assistant.io/integrations/go2rtc/

felipecrs avatar Nov 15 '24 22:11 felipecrs

Hi Alexx, thanks for writing this up. I am a nabu casa subscription user and I've been using your go2rtc addon & "WebRTC Camera" integration for a long time. I also use the custom card. I've never been able to get RTC to work remotely so the custom card switches to MSE when my phone is on 5G. This has been working fine for the most part.

Since you also mentioned that if I keep using my current setup, I can reduce the number of connections to the camera, I think I will keep everything the way it is.

However, my question: Am I somehow able to use Nabu Casa's external RTC turn server while using my current setup? It would be nice to be able to use RTC remotely.

Maes152 avatar Nov 18 '24 07:11 Maes152

  1. First you have to make sure that the stream uses the H264 codec. Because H265 will be through MSE anyway.
  2. It's reasonable to use TURN from Nabu Casa if you're paying for it anyway. It will only work with a standard lovelace card.
  3. You can only use one go2rtc from an addon. And configure HA to use it for the standard card.
  4. To guarantee one connection to the camera - you need to configure it in go2rtc, then add it to HA from go2rtc (generic rtsp). Because a standard card will connect both the old and new way to the camera. And this is already two connections at the same time.

AlexxIT avatar Nov 18 '24 08:11 AlexxIT

Thanks for the quick response, that was helpful.

I've setup HA in configuration.yaml to use the go2rtc addon, but I don't think it's working. When I create a picture-glance card it is seemingly slower than the custom card. It's also running about 7 seconds behind. Finally, I don't see an additional stream popup in go2rtc. But to be honest, I have no idea how to confirm that the card is actually using RTC....

This is what I added in the configuration.yaml: go2rtc: url: http://localhost:1984

Anyway I think I prefer the custom card over the picture-glance card any day of the week. If only because it displays the connection technology on the top right corner.

Will there ever be a change to the custom card so that it is able to use Nabu Casa's turn server?

Maes152 avatar Nov 18 '24 08:11 Maes152

Adding TURN from Nabu Casa to a custom card isn't easy. I don't have time for that yet. And need to ask HA core team for permission to do it.

PS. If the standard card has a white time slider, that's old HLS technology. If the time slider is gray (inactive) - it is WebRTC.

AlexxIT avatar Nov 18 '24 09:11 AlexxIT

Apologies Alex, only new and actually had installed gotoRTC brilliant work by the way. After your post here, I am even more confused as you don't seem to make a destination with gotoRTC and webRTC. I know one is the add-on and the second is the integration to HA. Is it a cut down version of gotoRTC and therefore webRTC is no longer needed? What about the custom card?

I have Hikvision for external cameras so from your post I am sure I need the original add-on setup anyway.

meremortals70 avatar Dec 08 '24 01:12 meremortals70

After my own not so big experience I have turned Off the built-in HA go2rtc excluding it from the default_config.

  • HA developers implemented go2rtc configuration in strange way: after each reload the go2rtc's config file is generating automatically under random name. That fact doesn't allow to customize go2rtc's config for permanent using and forces to use another additional instance of go2rtc.
  • maybe it's my own wrong suspicions (there's another suspect - ONVIF integration which I have turned Off also), but when I left the go2rtc running alone in separate Docker container - my video streams became a "rock-solid" instead of periodical frequent glitches and interrupts in default environment. (BTW, questions arose about the work of containerized go2rtc, which prompts me try to run a pure binary).

And I’m not alone, there are many topics on the Internet with similar claims. But for some reason the problem remains. I understand - "open source" and all that. But then you either don't mention this built-in integration and settings for it, or provide the ability to configure it for permanent use and this will eliminate the need to launch an additional instance of go2rtc with the possibility of mutual conflicts. Now HA has already reached a state where too many unresolved problems have accumulated, and the developers either do not have time or do not want to solve them, but focus on adding new decorations and minor improvements to the external interface. I am writing all this to the fact that of course you can be proud (and deservedly so) of the fact that your development has become part of some solid project, but maybe, as an author, it is worthwhile to check a little more deeply how correctly this is done.

warez4me avatar Sep 11 '25 11:09 warez4me

HA supports connecting to your own go2rtc installation (for advanced users) https://www.home-assistant.io/integrations/go2rtc/

For basic users, everything is done in such a way that they don't even know what go2rtc is.

go2rtc was not designed to solve all user problems automatically. If the camera is of high quality from a normal brand, everything will work well out of the box. If the camera has non-standard behavior, go2rtc can solve this in most cases. But with the user's involvement and with additional settings.

We are communicating with the authors of HA about the function "automatically make the stream normal in any case". I hope something like this will appear in future versions.

AlexxIT avatar Sep 11 '25 11:09 AlexxIT

Ok. Only two questions, just for better understanding.

  • For what reason after each reload the HA creates a new automatic copy of config for built-in go2rtc?
  • For what purpose and what process automatically inserts new streams into the go2rtc configuration in accordance with the camera entities recently created in HA?

warez4me avatar Sep 11 '25 12:09 warez4me

  1. Because they don't need a persistent configuration
  2. Through the go2rtc REST APIs

Note these decisions were taken without @AlexxIT's involvement as far as I understand (please correct if I'm wrong), so maybe this is not the best place to ask about it.

felipecrs avatar Sep 11 '25 14:09 felipecrs

  1. The current architecture of HA does not allow keeping any process constantly running inside HA. It will be rebooted together with HA. My custom component has been working exactly the same way for several years now - https://github.com/AlexxIT/WebRTC
  2. Those who don't like it can use a separate addon. Both my component and the HA core support it. If you are an active camera user, I would recommend this way. If you open cameras a couple of times a week, you can leave it as is.
  3. I didn't write the go2rtc integration code. But its logic quite accurately repeats my custom component WebRTC.

AlexxIT avatar Sep 11 '25 14:09 AlexxIT

Yeah, now I see some misunderstanding from myself. For a newbie there's too many info. And when You read that "You can install go2rtc in several ways ..." or "It will be automatically installed..." or "It is already built-in.. and You have nothing to do.." ... I got thinking that I can freely use all possibilities of go2rtc using any of this options. And most misleading is the name "WebRTC camera" that in its docs is called a "custom component" and appears for user as custom HA card. In the same time the go2rtc docs among the other options for install mentions "..the Integration" but not the "component" (who will follow the link at fast look?). Before I have seen that HA itself contains a go2rtc integration. 2+2... Now I see that HA's built-in go2rtc is don't mention anywhere in docs (and it would be nice to do this) in the meaning of what to do or better what not to do with it. At the same time now I don't see any point in creating HA camera entities. Perhaps only for ONVIF PTZ use. But HA's ONVIF support for PTZ raises a lot of questions compared to its de-facto standard implementation in the Onvif device manager. Myself I have found another way to produce PTZ actions and deal with other Onvif stuff. Return to HA's buit-in go2rtc I can say that I don't really know what exactly it can do and how. That's why my choice is to turn it Off. And it really had a positive effect on the stability of video streams.

warez4me avatar Sep 12 '25 06:09 warez4me

Now I see that HA's built-in go2rtc is don't mention anywhere in docs (and it would be nice to do this) in the meaning of what to do or better what not to do with it.

I am improving that in https://github.com/AlexxIT/go2rtc/pull/1720 btw.

Return to HA's buit-in go2rtc I can say that I don't really know what exactly it can do and how.

Its goal is to simply reduce the latency when viewing camera streams from camera entities through the built-in Picture Glance card.

If you add your entity through the built-in ONVIF integration, and your only goal is to be able to stream such entity in your Home Assistant dashboard, and the Picture Glance card is good enough for you, then you may not need to tinker with anything else.

And that's a quick win for starters.

felipecrs avatar Sep 12 '25 15:09 felipecrs

Its goal is to simply reduce the latency when viewing camera streams from camera entities through the built-in Picture Glance card. .... And that's a quick win for starters.

And.. That's all? Then why should I, as a starter, know about - Configuration Variables ... debug_ui boolean (Optional, default: false) Enables the UI of the go2rtc, which helps debugging WebRTC issues. The debug_ui should only be enabled during debugging as it will expose port 11984 without any authentication! ... Here we got 3 keywords: integration, go2rtc, which helps WebRTC A simple search leads us to a "custom component" (or perhaps it's some kind of advanced custom card), and its documentation says that it needs go2rtc to work. But we've already found it! However, we were not told that any of our changes to its configuration are not saved after the restart. But they said that to learn more about go2rtc, refer to the project’s GitHub page I'm studying the go2rtc's documentation, I don't see any special instructions, and then I can count on using the built-in go2rtc for my tasks. That's what's confusing.

warez4me avatar Sep 12 '25 18:09 warez4me

You shouldn't know any of that. It just works out of the box. You don't even need to know what WebRTC or go2rtc is.

You have found this information because you searched for it. 😅

felipecrs avatar Sep 12 '25 20:09 felipecrs

Yes, and now there is such a situation that the level of my confusion and/or misunderstanding will depend on the order in which I find this information. The puzzle is gradually taking shape, and I think I understand why new streams are appearing in config for the new camera entities. HA uses them to work with the Picture Glance card. Ok. Then why not be more flexible and use go2rtc's ability to work with multiple configs? Define your internal streams in a separate file, and let the user create his own config under a standard or custom name in the common configuration folder and everyone will be happy (seems I was trying to do so in the beginning). And then no addons will be needed. Well, what if the user is a kinda advanced and thinks that his external go2rtc is cooler than our built-in one. Ok, we can provide a config with the definition of internal streams as additional for load by the external go2rtc. Definitely it can do this if so was written in its docs. Or it can't? But there must be an opportunity.. The reason for such reflections is the fact that it is probably better to use a single process instead of several independent and somewhat competing ones that will allocate resources more optimally. And in the end, I want to see my config the way I created it without the "extra" streams.

warez4me avatar Sep 13 '25 08:09 warez4me

Then why not be more flexible and use go2rtc's ability to work with multiple configs?

That's an advanced use case in Nabu Casa's perspective, and that's exactly why the official integration allows you to supply your own go2rtc url.

The reason for such reflections is the fact that it is probably better to use a single process instead of several independent and somewhat competing ones that will allocate resources more optimally.

When you set the go2rtc url in the official go2rtc integration, the official integration will not start any go2rtc process.

felipecrs avatar Sep 13 '25 13:09 felipecrs

That's what I'm talking about. Just need to write these couple dozen words from your several recent comments in addition to what already is. And then me or people like me wouldn't have to waste own time on stupid experiments and Google and then not write hundreds of words here.

warez4me avatar Sep 13 '25 15:09 warez4me

Right. By the way all these documents are open source, and contributions to improve them are generally welcome.

felipecrs avatar Sep 13 '25 15:09 felipecrs

As I see, You have know so much about this. My IP video experience is about 3 months and I have more questions then answers. I don't think I'm the more suitable contributor of the two of us. How about the copy-paste right now ;) No offense.

warez4me avatar Sep 13 '25 18:09 warez4me

Yeah, don't worry, I know the feeling. Even I am not very comfortable to contribute to these docs.

felipecrs avatar Sep 13 '25 19:09 felipecrs

Yeah, it's left to hope that the top guys will someday find it necessary to supplement the docs.

warez4me avatar Sep 13 '25 20:09 warez4me

I am at a loss getting a single usb camera to work.. I sit now for 2 days and just dont understand it.

streams:
  newusb: v4l2:device?video=/dev/video0&input_format=mjpeg&video_size=1920x1080&framerate=15

This was the content of my go2rts.yaml file. But I dont know where to put it now. Nothing in the new go2rts component agrees with it, and the documentation is non existent. No LLM out there no matter how premium and how long thinking can provide me a solution that works.

I come here with tears in my eyes in the hopes of some help... help?

Do I need to provide a url to... what? why? Why cant I set my own stream like it was?

And I also tried using just the addon, ignoring the built in solution. but then the entity viewer just doesnt work, as it tries to connect to the 1 prefixed port for something, even though i never mention it.

I am at a loss here

Edit: Well after 2 days it randomly started working with the go2rtc addon... I dont know what changed... I havent even restarted ha or reloaded anything... But after reding through this here, its just 1 single camera I will look at every few weeks. Having the service only run when its actually needed and not all the time does make sense. So using the built in version might be beneficial still.. so If someone can help me getting it to work wthout the addon I would be happz about that. looks like the addin does need quite some cpu

Edit Edit: I sweat it know when I wronte something into github... Now the error is back

Failed to start WebRTC stream: webrtc: streams: exec/rtsp [rtsp @ 0x7faae0aa0000] method DESCRIBE failed: 404 Not Found [in#0 @ 0x7faae0c12b00] Error opening input: Server returned 404 Not Found Error opening input file rtsp://127.0.0.1:18554/camera.usb_what?audio&source=ffmpeg:camera.usb_what%23audio%3Dopus%23query%3Dlog_level%3Ddebug&log_level=debug. Error opening input files: Server returned 404 Not Found

So somethgin is trying to access the 1 prefixed port again from the ha core go2rtc.. I dont know.. Also the stream has like a delay of 2-3 minutes.. hm

Liquidmasl avatar Oct 14 '25 19:10 Liquidmasl

The go2rtc documentation in Home Assistant could indeed be clearer that it does not accept a configuration file.

felipecrs avatar Oct 14 '25 20:10 felipecrs

The go2rtc documentation in Home Assistant could indeed be clearer that it does not accept a configuration file.

Yeah and it could explain how to get custom streams working still..

Liquidmasl avatar Oct 14 '25 20:10 Liquidmasl