felipecrs / hass-expose-camera-stream-source

Allows to import Home Assistant cameras into go2rtc and Frigate
MIT License
100 stars 4 forks source link

And how to configure when go2rtc is running in Frigate, and Frigate is running in Docker on another machine #41

Closed jastden closed 1 week ago

jastden commented 1 week ago

And how to configure when go2rtc is running in Frigate, and Frigate is running in Docker on another machine

felipecrs commented 1 week ago

The essence of this applies:

https://github.com/felipecrs/hass-expose-camera-stream-source#when-go2rtc-is-running-via-docker

felipecrs commented 1 week ago

If you are using Tuya cameras, you can also use:

https://github.com/felipecrs/hass-expose-camera-stream-source#bonus-importing-tuya-cameras-to-go2rtc-without-home-assistant

Then you don't need Home Assistant.

jastden commented 1 week ago

The essence of this applies:

https://github.com/felipecrs/hass-expose-camera-stream-source#when-go2rtc-is-running-via-docker

I can't use this option because after adding an entry about go2rtc to docker-compose, I have 2 instances of go2rtc running. Let me remind you once again that my go2rtc was created automatically in frigate when I launched docker-compose for frigate. Here is my docker-compose for frigate:

version: "3.9"
services:
  frigate:
    container_name: frigate-pro
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
    deploy:    # <------------- Add this section
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1 # number of GPUs
              capabilities: [gpu]
    environment:
      - YOLO_MODELS=yolov7-320
      - USE_FP16=false
    shm_size: "600mb" # update for your cameras based on calculation above
    devices:
      - /dev/bus/usb:/dev/bus/usb  # Passes the USB Coral, needs to be modified for other versions
      - /dev/apex_0:/dev/apex_0    # Passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
      - /dev/video11:/dev/video11  # For Raspberry Pi 4B
      - /dev/dri/renderD128:/dev/dri/renderD128 # For intel hwaccel, needs to be updated for your hardware
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /opt/frigate/config/config.yml:/config/config.yml
      - /media:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "1984:1984"
      - "9150:5000"
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp

I do not understand how this should work, I remind you that frigate is running on another machine with a different address other than HA, thank you in advance for your help!

jastden commented 1 week ago

If you are using Tuya cameras, you can also use:

https://github.com/felipecrs/hass-expose-camera-stream-source#bonus-importing-tuya-cameras-to-go2rtc-without-home-assistant

Then you don't need Home Assistant. This option is more suitable for me, but there are two things that stop me: 1 - I do not understand how to install this script, I am new to linux, and your instructions are for advanced users 2 - I do not know if my intercom can broadcast in RTSP? I have taya tokens! I tried to install go2rtc as an add-on in home assistant and I managed to get an image using your "When go2rtc is installed as an add-on" method, but the performance on the machine with home assistant is very poor, and I have 12 cameras. Therefore, go2rtc runs on more powerful hardware. I will be very grateful for your help! photo_2024-10-31_16-08-22 photo_2024-10-31_16-08-17

felipecrs commented 1 week ago

You don't need the go2rtc add-on if you have it running on Frigate. I meant that the instructions for go2rtc running as docker apply in essence for when Frigate is running as docker.

1 - I do not understand how to install this script, I am new to linux, and your instructions are for advanced users

All you need to do is to download the script to the same directory where you have your frigate.yaml file. Then, in your go2rtc configuration you can call it with python3 /config/script_name.py.

PS: I don't think my instructions are for advanced users. If you know how to deploy Frigate with docker, then I think that's sufficient knowledge to understand my instructions.

2- I do not know if my intercom can broadcast in RTSP?

Neither do I, you have to test it by yourself. :)

And I suggest you test it before adding to the go2rtc configuration. Just call the script as the README suggests and see if it outputs a RTSP link.

felipecrs commented 1 week ago

Sorry. I deleted your comment because you shared credentials to your Tuya IOT account.

Looks like you need to Subscribe to the IoT Video Live Stream. Here's how it can be done: https://github.com/azerty9971/xtend_tuya/blob/main/docs/enable_webrtc.md.

But hey, you probably don't need to do that if you do it from Home Assistant. If you wait, I can write a guide for when go2rtc is running within Frigate within docker.

jastden commented 1 week ago

Sorry. I deleted your comment because you shared credentials to your Tuya IOT account.

Thanks, I didn't think about security!

Looks like you need to Subscribe to the IoT Video Live Stream. Here's how it can be done: https://github.com/azerty9971/xtend_tuya/blob/main/docs/enable_webrtc.md.

I did as you said and I did get the RTSP link, I'm glad, but I don't understand where I need to put the file: get_tuya_stream_url.py I copied it to opt/frigate/config but go2rtc does not see it. image

But hey, you probably don't need to do that if you do it from Home Assistant. If you wait, I can write a guide for when go2rtc is running within Frigate within docker.

Of course I will wait for this, I really don't fully understand what folder should be in, I'm confused, I'll be very glad if you help. Thanks!!!!

felipecrs commented 1 week ago

It should be like:

go2rtc:
  streams:
    my_camera:
      - echo:python /config/get_tuya_stream_url.py <device id> <client id> <client secret> https://openapi.tuyaus.com RTSP

In your frigate.yaml.

jastden commented 1 week ago
- echo:python /config/get_tuya_stream_url.py

I've tried it many times :) image

go2rtc:
streams:
intercom:
- echo:python /config/get_tuya_stream_url.py ********** ********** ***************** https://openapi.tuyaeu.com RTSP
outside_left:
- and so on........
felipecrs commented 1 week ago

Oh, my bad, I meant python3 not python, please try again.

9e337ac018b7460e1f4da49e5885f7d09f972e9b

jastden commented 1 week ago

Oh, my bad, I meant python3 not python, please try again.

9e337ac

image

Without changes :) Or download the file again?

felipecrs commented 1 week ago

Take the RTSP link you were able to generate and play it on VLC. Be quick, it expires in a few seconds if not opened.

If it doesn't work in VLC, it won't work in go2rtc either.

jastden commented 1 week ago

Take the RTSP link you were able to generate and play it on VLC. Be quick, it expires in a few seconds if not opened.

If it doesn't work in VLC, it won't work in go2rtc either. image

I received the broadcast, it's not in RTSP but in HLS, thanks for this promotion, but it still doesn't work in go2rtc

felipecrs commented 1 week ago

I have a camera like that, which only works through HLS. Unfortunately I was never able to make it work on go2rtc.

This is the relevant issue in go2rtc side:

jastden commented 1 week ago

I have a camera like that, which only works through HLS. Unfortunately I was never able to make it work on go2rtc.

This is the relevant issue in go2rtc side:

Then the only option left is to pull the stream from the Home assistant? And wait for instructions from you ;)

felipecrs commented 1 week ago

Not really. The stream from Home Assistant is always RTSP. If RTSP did not work for you, then the stream from Home Assistant won't work either.

But anyway, you can try playing the stream from Home Assistant in VLC.

Just call:

bash /config/custom_components/expose_camera_stream_source/get_stream.sh camera.my_camera

Inside the Terminal add-on.

jastden commented 1 week ago

Not really. The stream from Home Assistant is always RTSP. If RTSP did not work for you, then the stream from Home Assistant won't work either.

But when I installed go2rtc as an add-on in HA for the test and wrote to go2rtc.yaml : go2rtc: streams: my_camera:

felipecrs commented 1 week ago

Oh. Got it. Well, here are the instructions:

https://github.com/felipecrs/hass-expose-camera-stream-source/blob/new-guide/README.md#when-go2rtc-is-running-within-frigate-via-docker

42

Please give it a try.

felipecrs commented 1 week ago

Use:

- HA_TOKEN=tokenhere
felipecrs commented 1 week ago

This happens because you are using a different syntax for the environment.

You can't mix the syntaxes.

jastden commented 1 week ago
- HA_TOKEN=tokenhere

Thank you, I am very grateful for your help, everything worked out!!! Please tell me it works over the Internet, but if there is a way to make it work locally?

felipecrs commented 1 week ago

Happy to help.

I believe the only way to make it work locally is by jailbreaking your camera to allow it to expose an RTSP stream itself.

Maybe this in go2rtc would also make it run better, I don't know: