AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
3.86k stars 316 forks source link

Re-using homekit URL from HomeAssistant results in ffmpeg initialization error #1082

Open visigoth opened 2 months ago

visigoth commented 2 months ago

I am using Frigate's builtin go2rtc running in a docker instance. I have a HomeAssistant docker instance on the same box. The config path for HomeAssistant is mapped into the Frigate docker instance at /hass_config.

I have go2rtc configured like this inside the frigate configuration, and the frigate configuration is below that


go2rtc:
  rtsp:
    username: "camera"
    password: "XXXXXXXXX"
  hass:
    config: "/hass_config"
  streams:
    doorbell:
      - homekit://192.168.0.71:49152?client_id=...&client_private=...&device_id=...&device_public=...

cameras:
  doorbell:
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/doorbell
          input_args: preset-rtsp-stream
          roles:
            - detect
            - record
      hwaccel_args: preset-intel-qsv-h264

note i have a number of other plain PoE RTSP cameras that are working fine with go2rtc + frigate doing both detection and recording. the above snippet just shows the one HomeKit camera i have for the doorbell. also note that i tried hass:camera.doorbell as well for the URL but i kept getting no entity_id and 404 errors in the log. i manually formatted the homekit:// URL as above.

when i start things up, i get Could not find codec parameters for stream 0 (Video: h264, 1 reference frame, none): unspecified size

i tried increasing the analyzeduration and probesize values as suggested, but that didn't work either.

the information ffmpeg is able to get out of go2rtc is:

[tcp @ 0x557adb5cd580] Successfully connected to 127.0.0.1 port 8554
[rtsp @ 0x557adb5ca540] SDP:
v=0
o=- 1 1 IN IP4 0.0.0.0
s=go2rtc/1.8.4
c=IN IP4 0.0.0.0
t=0 0
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=4D001F
a=control:trackID=0
AlexxIT commented 2 months ago

Is the Frigate container running with the network host setting?

visigoth commented 2 months ago

apologies for taking a while to respond, but i don't get a lot of time to look into home networking issues.

for my case, i am running frigate along with other containers on a MAC VLAN network - i.e. each container has its own virtual NIC that shows up on the physical network.

AlexxIT commented 2 months ago

Go2rtc should run in the host network to get the HomeKit protocol working

visigoth commented 1 week ago

got it; i would rather not move to the host networking mode. having each container be a separate endpoint on the network makes traffic shaping and firewall rules easier to manage.

fwiw, the doorbell camera is routable for the HomeAssistant docker container as i have used HA as the HomeKit controller for it. also, the Frigate container can talk to the HomeAssistant container since i have camera entities in HomeAssistant for the go2rtc-reflected RTSP cameras.

i suppose i could host another go2rtc instance just to reflect the doorbell camera as an RTSP stream that Frigate can consume, but that seems convoluted.

given that the containers are routable to each other, and HA can talk to the doorbell camera, and the containers are under the same traffic shaping rules, what is it about the HomeKit protocol that requires host-mode networking?

AlexxIT commented 4 days ago

Additional inbound ports for this protocol to work. mDNS and SRTP. They are static. Many streaming protocols use random inbound ports. Maybe some additional docker configuring of the docker container will be enough to make everything work. I don't know. I have no plans to test and support modes other than network host. It would take a lot of effort to support an issue (like this one) that shouldn't have come up.