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
4.9k stars 396 forks source link

How does go2rtc prioritize streams from the same camera? #308

Closed redelacruz closed 1 year ago

redelacruz commented 1 year ago

Hi, Alex!

I was just wondering how go2rtc prioritizes multiple streams from the same camera. I have a CCTV connected via ethernet and Wi-Fi, with different IPs for each connection type.

So, in my config, I have the following:

streams:
  outdoor_front_hd: 
    # wired
    - rtsp://secret:secret@192.168.2.11:554/user=admin_password=_channel=0_stream=0&protocol=unicast&onvif=ture.sdp?real_stream
    # wireless
    - rtsp://secret:secret@192.168.2.10:554/user=admin_password=_channel=0_stream=0&protocol=unicast&onvif=ture.sdp?real_stream

Given my config above, will go2rtc prioritize the wired stream because it comes first in the config? Or does it prioritize streams (exactly the same stream, just from different addresses) some other way?

Ideally, I want it to prioritize the wired stream but use the wireless as a failover in case some smartass decides to cut the cable to the camera before sneaking into my home.

AlexxIT commented 1 year ago

Go2rtc queries all sources one by one. It will stop when all client codecs will match. If the first source has all the codecs, go2rtc will not run the second source. If the first source is unavailable, go2rtc will request the second source. Everything will work like you want.

redelacruz commented 1 year ago

Awesome! Thanks!