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.87k stars 394 forks source link

Lots of active connections since v0.1-rc.7 #156

Closed felipecrs closed 1 year ago

felipecrs commented 1 year ago

It seems to just increase over time, endlessly.

https://user-images.githubusercontent.com/29582865/211223101-75512d42-bd83-489e-8d73-83ac7dce7ffb.mp4

felipecrs commented 1 year ago

Logs give me this:

image

NickM-27 commented 1 year ago

Interesting, I'm not seeing this personally on my setup

AlexxIT commented 1 year ago

Show your config for problem streams

avico78 commented 1 year ago

Same here - only one page open for cameras but its shows more online

go2rtc 0.1-rc.7 - running on docker image

On on Compose:

services:
  go2rtc:
    container_name: go2rtc  
    image: alexxit/go2rtc:3.0-beta.4
    network_mode: host   
    restart: always
    volumes:
      - ./go2rtc.yaml:/config/go2rtc.yaml

go2rtc.yaml


streams:
  salon_ceiling_go2rtc: rtsp://hauser:xxxxxx@192.168.1.138/cam/realmonitor?channel=1&subtype=0
  salon_desk_go2rtc: 
    - rtsp://hauser:xxxxxx@192.168.1.92/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif    
    - ffmpeg:rtsp://hauser:xxxxxx@192.168.1.92/cam/realmonitor?channel=1&subtype=0#audio=opus
  pergula_go2rtc: rtsp://hauser:xxxxxx@192.168.1.200/cam/realmonitor?channel=1&subtype=0
  front_go2rtc: rtsp://hauser:xxxxxx@192.168.1.55/cam/realmonitor?channel=1&subtype=0
  intercom_go2rtc: rtsp://hauser:xxxxxx@192.168.1.110:554/cam/realmonitor?channel=1&subtype=0  

log:
  level: error  # default level
  api: error
  rtsp: error
  streams: error

api:
  listen: ":1984" 

rtsp:
  listen: ":8554" 

webrtc:
  listen: ":8556"  # address of your local server (TCP)
  candidates:
    - stun:8556  # if you have dynamic public IP-address

# not in use currently
ngrok:
  command: ngrok start --all --config ngrok.yaml
avico78 commented 1 year ago

+

08:40:30.896 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="sdp: invalid value ``" url=rtsp://192.168.1.113:8554/intercom_go2rtc
08:40:30.975 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="sdp: invalid value ``" url=rtsp://192.168.1.113:8554/intercom_go2rtc
08:40:30.998 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="sdp: invalid value ``" url=rtsp://192.168.1.113:8554/intercom_go2rtc
08:40:31.024 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="sdp: invalid value ``" url=rtsp://192.168.1.113:8554/intercom_go2rtc
08:40:31.060 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="sdp: invalid value ``" url=rtsp://192.168.1.113:8554/intercom_go2rtc
08:40:31.060 ERR github.com/AlexxIT/go2rtc/cmd/mjpeg/mjpeg.go:120 > error="source 0 error: sdp: invalid value ``"
felipecrs commented 1 year ago

Here is my config:

webrtc:
  listen: ":8555"
  candidates:
    - 192.168.1.10:8555
    - stun:8555

streams:
  rua_hd_aac:
    - ffmpeg:rtsp://192.168.1.33:554/0/av0#video=copy#audio=aac
  camera.rua:
    - rtsp://192.168.1.33:554/0/av1
    - ffmpeg:camera.rua#audio=aac
  camera.morro:
    - rtsp://192.168.1.34:6554/stream_1
    - ffmpeg:camera.morro#audio=aac
  camera.portao:
    - rtsp://192.168.1.32:6554/stream_1
    - ffmpeg:camera.portao#audio=aac
  camera.terreiro:
    - rtsp://192.168.1.31:6554/stream_1
    - ffmpeg:camera.terreiro#audio=aac
  video_porteiro_hd_aac:
    - ffmpeg:rtsp://192.168.1.40/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif#video=copy#audio=aac
  camera.video_porteiro:
    - rtsp://192.168.1.40/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
    - ffmpeg:camera.video_porteiro#audio=aac
felipecrs commented 1 year ago

Just to say in case others are in the same situation, I had to downgrade to beta 6. If running the Hass add-on, you can downgrade from the backups if you took one when updating.

avico78 commented 1 year ago

Just to say in case others are in the same situation, I had to downgrade to beta 6. If running the Hass add-on, you can downgrade from the backups if you took one when updating.

running HA and go2rtc on dockers, may i ask(for learning) for the reason having 2 streams per each camera ? is it transcoding the audio to aac? case yes,is it needed cause you can't do it in camera itself? is overloading cpu?

felipecrs commented 1 year ago

may i ask(for learning) for the reason having 2 streams per each camera ? is it transcoding the audio to aac?

Yes.

case yes,is it needed cause you can't do it in camera itself?

Yes. My camera does not allow me to set the audio codec.

is overloading cpu?

I don't think so:

image

AlexxIT commented 1 year ago

@felipecrs What cameras do you have set up in Hass? Generic camera.rua with url rtsp://192.168.1.33:554/0/av1? Or generic camera.rua with url rtsp://localhost:8554/camera.rua?

felipecrs commented 1 year ago

None.

In Hass, all my cameras comes from Frigate 0.11 (i.e. RTMP). But that was not supposed to change anything, because I use RTSPToWebRTC with go2rtc, when Hass requests a stream to go2rtc, thus bypassing the Frigate RTMP and fetching directly from camera configured in go2rtc.yaml for the best latency.

avico78 commented 1 year ago

@felipecrs , correct me if I wrong but you have 2 different connections to the cameras one from Frigate and rtmp use in Hass + connection in go2rtc . why not letting go2rtc connect and use go2rtc rtsp camera connection both in Frigate and Hass? for me it improve the overall performance. (although webrtc not working externally when using RTSPToWebRTC -> go2rtc)

second ,Frigate will deprecate rtmp to new reststream : https://github.com/blakeblackshear/frigate/releases beside that ,it will also offer webrtc inside frigate camera live view which one stabilize will be awesome .

AlexxIT commented 1 year ago

Lots of active connections - looks like it is old problem.

Self link to same stream also broken in the rc.7

streams:
  camera.portao:
    - rtsp://192.168.1.32:6554/stream_1
    - ffmpeg:camera.portao#audio=aac

This variant will temporary work before fix

streams:
  camera.portao:
    - rtsp://192.168.1.32:6554/stream_1
    - ffmpeg:rtsp://192.168.1.32:6554/stream_1#audio=aac
felipecrs commented 1 year ago

@felipecrs , correct me if I wrong but you have 2 different connections to the cameras one from Frigate and rtmp use in Hass + connection in go2rtc . why not letting go2rtc connect and use go2rtc rtsp camera connection both in Frigate and Hass? for me it improve the overall performance. (although webrtc not working externally when using RTSPToWebRTC -> go2rtc)

second ,Frigate will deprecate rtmp to new reststream : https://github.com/blakeblackshear/frigate/releases beside that ,it will also offer webrtc inside frigate camera live view which one stabilize will be awesome .

First of all, I'm aware that Frigate 0.12 changes everything. But I'm not upgrading yet.

Now, still on Frigate 0.11, all the camera feeds in my frigate.yaml are pointing to go2rtc feeds, so no, I'm not connecting to the camera twice.

AlexxIT commented 1 year ago

Should be fixed https://github.com/AlexxIT/go2rtc/releases/tag/v0.1-rc.8

felipecrs commented 1 year ago

Thanks a lot, it's fixed indeed!