How-to guide for getting nest into BI, including doorbell gen2

B-Murda

Getting the hang of it
Jun 16, 2020
34
26
USA
Figured would share this. It's worth mentioning that I'm helping Ken try to get native Google support in the tool but it's also worth mentioning Google does funky things and complicates this so may or may not ever turn into reality.
These instructions may not be 100% perfect. I got a little lazy and used AI to help write it due to too many steps hah. You can find various guides already online for a lot of this and cobble together what is needed.
IF you happen to use Home Assistant and have nest cameras setup in that you likely did the Pre-Req's and could skip all of that. You can get the refresh token directly from HA in core.config_entries under .storage (hidden) folder. It will be on a line that contains the word nest. You can get to this file multiple different ways (using an add-on, ssh, etc. etc.)

In the meantime here is how I record my nest cameras into BI (since I refuse to pay google due to things they keep doing and have yet to replace everything)
You are already running a windows box because hey, you have BI so lets just keep it all local to this. You CAN run this in a container, linux etc. if you want but honestly google streams are very light weight and this only used a few % of CPU. You can do hardware decoding instead of CPU even but I'm going to keep this very simple/basic for everyone and not go into details like that. You can research to figure more if you want.

For steps 1-14 if you want a better view with images you can check out a Home Assistant guide here: Google Nest

Pre-Req: (this will cost you a one-time fee of $5 to google.)
1) Go to: Google Cloud Platform
2) Click the dropdown at the top and select “New Project”.
3) Give it a name like go2rtc-nest and create it.
4) In your project, go to APIs & Services > Library.
5) Search for "Smart Device Management API" and enable it
6) Go to APIs & Services > Credentials.
7) Click “Create Credentials” > OAuth Client ID.
8) Select Web application.
9) Add as the authorized redirect URI (or wherever you will run the auth).
10) Note your: Client ID & Client Secret
11) Go to the Google Device Access Console.
12) Click Get Started and accept terms (there may be a $5 registration fee).
13) Create a Project and link it to the Google Cloud Project you just made.
14) Note your: Project ID & Project number
15) To authenticate go2rtc, you’ll need a refresh token using OAuth 2.0.
Various ways exist to do this. The one I used originally doesn't work anymore. I found if you ask google gemini "I'm using go2rtc to stream my nest cameras. How do I get a refresh token?" it will give you steps that may work. You can also use home assistant again if you have that already, which is what I switched to since I had that too.

Configure steps:

1) Download go2rtc (all releases here) Win x64 zip here
2) Extract only go2rtc to a directory of your choice. This is where it will live forever. It's a standalone app, no installing.
3) Download ffmpeg for windows. Official site here with a direct windows download here
4) Extract only ffmpeg.exe to the same directory as go2rtc (to keep stuff cleaner/together).
5) Run go2rtc. It will open a command window and start the service. Leave this running. Later you can research running this as a service, starting it at boot-up or a million other things.
6) Go to the machineIP:9184 (this can be done from the machine itself or a remote machine if your windows firewall isn't blocking...
7) You are now looking at the main screen where you would typically see available camera/streams. No authentication is used so be careful how you expose this. You CAN add authentication but I wouldn't call it a good secure method still. This is one reason I just recommend running this on BI directly because you can block it on the machine so only localhost can hit it etc.
8) Go to add and pick "Google Nest".
9) Fill this all in and hit login. Hopefully you don't get an error and it will present you a list of cameras. The format will be nest: and a bunch of stuff. Copy each of these lines into notepad or somewhere as they will go away and you have to do the other steps each time to get again.
10) Go to config
11) Paste all of this in BUT you will replace some items:
ffmpeg:
bin: "C:\\Users\\NAME\\Downloads\\ffmpeg.exe"
doorbell_h264_profile: "-c:v libx264 -r 20 -g 25 -profile:v high -level:v 4.1 -preset:v fast -tune:v zerolatency -pix_fmt:v yuv420p"
streams:
Doorbell:
- nest:?client_id=REDACTED.apps.googleusercontent.com&client_secret=REDACTED&device_id=REDACTED&project_id=REDACTED&protocols=WEB_RTC&refresh_token=REDACTED
# 2. Create a stable, transcoded stream with the CORRECTED syntax
# This is the stable stream using the built-in ffmpeg source
Doorbell_stable:
- "ffmpeg:Doorbell#video=doorbell_h264_profile#width=960#height=1280#audio=aac"

Replace the nest:? portion with one of your cameras, In my example it's a doorbell. Feel free to change the Doorbell name but make note of the other areas you will need to change it.
The other variables you may need to play with are -r and -g on the profile line. So for the nest gen2 doorbell, I found these settings to work best. It's because the camera constantly changes quality and stream info such as fps, iframes etc and BI does not do well with this. This is one reason why we have to transcode and can't just create and rtsp stream. Or at least in my case. Maybe different nest cameras (older gen or hub's) are different, or maybe mine is just unstable....

See next post, seems hit a limit...
 
Last edited:
The -r is saying 20 fps and g is saying -25 iframe for around 0.75 (I know 1 is ideal) but I had stability issues with it being at 1. You can play around and test stuff out.
Hit save and restart. At this point you probably need to close the command window (or restart the service if you did that) for go2rtc and start it again. Make sure no errors show in red. Now when you go back to to the webgui you should see 2 streems. The first one is the native one. If you click stream it should work and will work fine in the browser. The second one is the transcode. Clicking stream on that should also work but has a delay in starting since it has to start the first one first and then transcode. This is the one BI will use (or feel free to experiment).
Now in BI you can add a camera and use (change the src to your proper one). Clear our username/password, disable keep alive and you should be good to go.

Hope this helps some of you. Again, this probably won't be perfect but my time was limited and wanted to get something out before I kept forgetting or never did. This way at least you can help each other etc. It's worth noting the refresh token may need updating from time to time. You can automate/script all of this. Be lazy and use AI to help if you need. Keep in mind doing so it will make mistakes and not work always. Also don't paste things into AI that contain your confidential stuff like keys and id's etc.

Anyway enjoy, hope it works out for you all. Experiment, improve, share!