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.14k stars 332 forks source link

High RAM usage and unexpected restart of Home Assistant #1241

Open pico1881 opened 1 month ago

pico1881 commented 1 month ago

For a few days I have encountered the unexpected restart of Home Assistant, after some analysis I found that the problem was due to excessive use of RAM above 90%. After further analysis I saw that the RAM was being used by go2rtc (see screenshot), but I don't see any errors in the log. After manually restart of go2rtc addon the RAM usage is about 2-5% go2rtc ram

porly1985 commented 1 month ago

I can confirm this behaviour. After restarting go2rtc the RAM usage is fine again.

image
dagleaves commented 1 month ago

I'm not Alex, but I've been investigating similar issues

  1. What version of go2rtc are you on?
  2. Are you using audio on any of your cameras via a secondary audio ffmpeg stream?
  3. If 2 is yes, do you notice a large number of consumers on your stream when your memory usage is high?
  4. What brand of cameras are you using?

I would also double check that your log level is set to debug or trace if you aren't seeing errors. If you are on info, most errors won't get reported.

alexandreghez commented 1 month ago

Same problem : I'm using go2RTC 1.9.4 i have a raspberry 4 and 3 cameras : 2 homekit (Aquara G2HPRO et EUFY) et 1 tapo C220 image

dagleaves commented 1 month ago

Same problem :

I'm using go2RTC 1.9.4 i have a raspberry 4 and 3 cameras : 2 homekit (Aquara G2HPRO et EUFY) et 1 tapo C220

Are you using an audio stream with it? I would encourage you to check the things I listed above to help identify the source of the issue

porly1985 commented 1 month ago

I'm not Alex, but I've been investigating similar issues

  1. What version of go2rtc are you on?
  2. Are you using audio on any of your cameras via a secondary audio ffmpeg stream?
  3. If 2 is yes, do you notice a large number of consumers on your stream when your memory usage is high?
  4. What brand of cameras are you using?

I would also double check that your log level is set to debug or trace if you aren't seeing errors. If you are on info, most errors won't get reported.

Hi dagleaves,

  1. 1.9.4 (WebRTC Camera + HA Addon)
  2. yes, all the audio goes through ffmpeg
  3. I will check it when it happens again, the high ram usage only occures from time to time in my case.
  4. 3 x Reolink + 1 x Tap C210

Thanks and greetings!

Update:

Just happened again.

image

This network is active all the time, even when cameras are not in use.

Here my camera config:

  camera.garten_main:
    - http://192.168.178.135/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=XXXXXX&password=XXXXXXX#video=copy#audio=copy#audio=opus
    - ffmpeg:camera.garten_main#audio=opus
AlexxIT commented 1 month ago

Memory graph screenshots are not much help to understand and detect the problem. The config part is already better. I don't know if it will be enough for the repeating of the problem.

pico1881 commented 1 month ago

In my case I solved removing this entry from config: "camera.camera1_sub": ffmpeg:{input}#video=copy#audio=opus#audio=aac

EDIT: the problem persists and causes HA reboot due to high RAM usage. At the moment I have uninstalled go2rtc add-on and I'm trying to use only WebRTC Camera custom component

alexandreghez commented 1 month ago

this is my configuration for streams part :

streams:
  eufy:
    - homekit://[IP]:46778?device_id=MACADDR&device_public=[PUBLIC]&client_id=[CLIENT_ID]&client_private=[CLIENT_PRIVATE]
   - ffmpeg:eufy#audio=aac#audio=opus
  aqara: 
    - homekit://[IP]:37833?device_id=MACADDR&device_public=[PUBLIC]&client_id=[CLIENT_ID]&client_private=[CLIENT_PRIVATE]
    - ffmpeg:aqara#audio=aac#audio=opus#bitrate=299K
  tapo: 
    - tapo://admin:[PASSWORD]@[IP]
    - ffmpeg:tapo#audio=aac