Go2rtc project - help thread

You can add camera entity_id to go2rtc config if you need transcoding:

streams:
  "camera.hall": ffmpeg:{input}#video=copy#audio=opus

or

  "camera.kitchen_display": 
    - "{input}"
    - ffmpeg:{input}#audio=opus

This is beautiful (although I haven’t actually tested it yet). Thanks for that!

Edit: tested it. Works great.

1 Like

It works for me as well! Fixed my Nest audio issue.

I was trying to get iframes to work, but I’m having some trouble exposing the api using nginx. The iframe works great if I use the local link, http://192.168.0.201:1984/webrtc.html?src=baby_cam_1, but that obviously doesn’t work remotely.

I tried exposing 192.168.0.201:1984 as a subdirectory of my domain using nginx and wasn’t able to get it working. I’m guessing there may be some special nginx settings that I have to put in, but I’m not sure exactly which. I tried setting the custom location without any special settings and got a 404 error. I then tried the following settings and also got a 404 error.

location /go2rtc/ {
   proxy_read_timeout 300;
   proxy_pass_header  X-Transmission-Session-Id;
   proxy_set_header   X-Forwarded-Host   $host;
   proxy_set_header   X-Forwarded-Server $host;
   proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;       
   proxy_pass         http://192.168.0.201:1984;
   }

I also tried adding the settings to the Advanced tab, and again 404 error.

Hey @nprez83 , this is how I’ve got mine setup and it works. Although I can’t get 2-way audio via Home Assistant yet (However, 2 way audio works by going directly to the url: https://mydomain.org/go2rtc/webrtc.html?src=frontdoor )
I just need to figure out how to get 2 way audio working through Home Assistant!

go2rtc.subfolder.conf:

location /go2rtc/ {
  include /config/nginx/authelia-location.conf; 
  proxy_set_header Host $host;
  proxy_set_header X-Ingress-Path "/go2rtc";
  proxy_set_header X-Forwarded-Scheme $scheme;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_pass http://192.168.0.22:1984/;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}
rewrite /go2rtc/(.*) /$1 break;

image

That’s all you need. This is temporary for me though. Be sure you understand this exposes your cameras to the internet.

I will be using the create link feature that’s in the current webrtc when it’s available to go2rtc.

1 Like

I’m guessing that has to do with how you have your cameras added to home assistant. If you use an iframe it should be the same as just using this directly.


            - camera_view: auto
              type: picture-glance
              title: null
              entities:
                - entity: input_select.tts_door_text_selection
                - entity: input_text.tts_door_text
                - entity: lock.front_door
              camera_image: camera.front_door_main
              hold_action:
                action: fire-dom-event
                browser_mod:
                  service: browser_mod.popup
                  data:
                    title: frontdoor_main Live
                    size: wide
                    content:
                      type: iframe
                      url: /go2rtc/webrtc.html?src=frontdoor_main
                      aspect_ratio: 75%

Yeah I’ve added that (https://mydomain.org/go2rtc/webrtc.html?src=frontdoor ) as a direct iframe but I don’t get the prompt to give permission access for microphone. This is the same when I access Home Assistant over both local (http://192.168.0.22:8123) and remote (https://homeassistant.mydomain.org)

It won’t work over http. Browser limitations.

But we long as it’s a good cert, it should over https. Mine is a letsencrypt cert but i doubt that matters.

What device are you using for the companion app? I’m on Android.

Yeah I’m aware it needs to be https for microphone to work, my cert is also letsencrypt - I’m using the Swag docker container for my nginx reverse proxy solution.

I’ve attempted the iframe & 2-way audio on both Firefox & Edge on Mac and Android Companion app & Chrome on my phone. None of them work, I just see the video feed but no 2-way communication.

Try using a rewrite like mine instead of the way you are handling it. Only to rule out things. And your location doesn’t need a trailing slash.

https://forum.nginx.org/read.php?11,286648

This is the way the actual nginx config looks like as written by nginx proxy manager in its actual conf files…

  location /go2rtc {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP		$remote_addr;
    proxy_pass       http://10.100.1.183:1984;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;
    rewrite /go2rtc/(.*) /$1 break;
  }

This is perfect! Works like a charm. Between having my iframes working now, and the recent fix to the Nest audio in beta 6, I now have two options for my cameras:

  1. Skip the RTSPtoWeb integration, use built in conversion for Nest cam, and iframes for my Foscams
  2. Use RTSPtoWeb integration, which allows the Foscams to work right off the bat, and use transcoding for Nest Cam.

Gotta love options, thanks again @calisro

In order for this to work without the rewrite, I Believe you would have had to change your ‘basedir’ for the api in the go2rtc config. Revert it and try the rewrite I used instead.

I didn’t have to make any adjustments to ‘basedir’ - the config above that I posted worked with the default go2rtc setup.
I tried your nginx config with the rewrite, it works fine but still doesn’t let me do 2-way audio inside Home Assistant itself :cry: Thanks for the info though!

webrtc integration dont work for me anymore (continues reconnection issues) and i’m trying to move to this project.

can someone make a foolproof tutorial on how to make cards from rtsp? I have read the whole topic but I still do not understand how to do it. I write the steps that I have managed to do so far:

  • I have successfully installed go2rtc
  • I added all rtsp streams as generic camera
  • these cameras have appeared on the go2rtc homepage

now I don’t know how to insert them in the cards, because the only entities that appear to me are the generic ones and not those of go2rtc

There’s nothing more you need to do. your picture glance or camera cars will connect with webrtc. If you experience ‘no audio’ or want to customize it further, then you can using the go2rtc.yaml.

I’ve finally got 2-way audio working via Home Assistant!

I created this go2rtc.html file (that points to my Go2RTC https webrtc page) and stored it under /www in my HA directory. This has the additional option "allow=“microphone *;” which activates the microphone allowing 2-way audio.

<html>
    <head>
    </head>
    <body>
          <iframe src="https://mydomain.org/go2rtc/webrtc.html?src=frontdoor" allow="camera *;microphone *" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0%;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    </body>
</html>

I then add that html file as an iframe card in Home Assistant, it now works for 2-way audio when I access my Home Assistant instance over https! :partying_face:

type: iframe
url: https://homeassistant.mydomain.org/local/go2rtc.html
aspect_ratio: 76%
2 Likes

That’s interesting. I never thought to ask but what kind of phone?
I read you were on a Mac. All apple devices? Trying to understand the commonality because all of my devices prompt for microphone permissions.

Android: chrome and companion app
Linux: chrome

Doesn’t your html embed an iframe in an iframe? Fyi that you can copy all the html pages from go2trc GitHub and put them in your www directory and run it directly from there with the "static_dir parameter.

Hey Rob,
I’m using a Samsung S20+ phone, tested with both Chrome & companion app.
For desktop I’m using macOS & Firefox & Edge.

Yeah the html embeds an iframe within an iframe (Inception lol), but for some strange reason it works! Otherwise I haven’t had any success getting the microphone permission prompt!

Good shout about manually copying the html pages, I had considered that but figured the current way I’ve set it up would be easier for future go2rtc updates etc.

I’ve tested things further, I notice that the 2-way audio doesn’t work EVERY time I attempt it; the microphone is active on my device as per the built in OS indicators but no audio comes out of my doorbell. I suspect this is a go2rtc issue however.

One last mention. You can use card_mod to embed iframes manually if you’re using it in a popup or similar. Still inception iframes :slight_smile: but at least you don’t have some extra code in your www directory.

              hold_action:
                action: fire-dom-event
                browser_mod:
                  service: browser_mod.popup
                  data:
                    title: frontdoor_main Live2
                    size: wide
                    content: |
                            <iframe src="https://xxxxx/go2rtc/webrtc.html?src=frontdoor_main" allow="camera *;microphone *" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0%;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>
                            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
1 Like

Are you still getting the “Failed to start WebRTC stream: Timeout handling WebRTC offer” error? I get it somewhat frequently with my Nest cam, which as of beta 6 is going through ffmpeg for audio transcoding (thanks for that btw, huge win for me). I’m not exactly sure if the timeout is set by go2rtc or by the RSTPtoWebRTC integration (my suspicion is it’s the latter).