blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.2k stars 1.76k forks source link

High CPU after upgrade to 0.13.0 - Make sure to set camera detect resolution #7828

Closed madasus closed 1 year ago

madasus commented 1 year ago

Describe the problem you are having

After upgrading from 0.12 to 0.13.0 Beta 1 I'm seeing really high CPU on my docker machine. Birdseye appears to be showing all the cameras all the time so I think maybe it is always sensing motion on the cameras?

Assume i just have something wrong in my config that isn't compatible with 0.13.x?

Version

0.13.0 Beta 1

Frigate config file

database:
  path: /db/frigate.db

mqtt:
  host: 10.2.1.171
  user: mqtt
  password: XXXXXX

ffmpeg:
#  hwaccel_args: -c:v h264_qsv
#  hwaccel_args: preset-intel-qsv-h264
  hwaccel_args: preset-vaapi

logger:
  # Optional: default log level (default: shown below)
  default: warning
  # Optional: module by module log level configuration
  logs:
    frigate.mqtt: error

detectors:
  coral:
    type: edgetpu
    device: usb

detect:
  max_disappeared: 500

timestamp_style:
  # Optional: Position of the timestamp (default: shown below)
  #           "tl" (top left), "tr" (top right), "bl" (bottom left), "br" (bottom right)
  position: "tl"
  # Optional: Format specifier conform to the Python package "datetime" (default: shown below)
  #           Additional Examples:
  #             german: "%d.%m.%Y %H:%M:%S"
  format: "%m/%d/%Y %H:%M:%S"
  # Optional: Color of font
  color:
    # All Required when color is specified (default: shown below)
    red: 255
    green: 255
    blue: 255
  # Optional: Line thickness of font (default: shown below)
  thickness: 1
  # Optional: Effect of lettering (default: shown below)
  #           None (No effect),
  #           "solid" (solid background in inverse color of font)
  #           "shadow" (shadow for font)
  effect: solid

birdseye:
  # Optional: Enable birdseye view (default: shown below)
  enabled: True
  # Optional: Width of the output resolution (default: shown below)
  width: 1280
  # Optional: Height of the output resolution (default: shown below)
  height: 720
  # Optional: Encoding quality of the mpeg1 feed (default: shown below)
  # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
  quality: 8
  # Optional: Mode of the view. Available options are: objects, motion, and continuous
  #   objects - cameras are included if they have had a tracked object within the last 30 seconds
  #   motion - cameras are included if motion was detected in the last 30 seconds
  #   continuous - all cameras are included always
  mode: objects
  restream: true

objects:
  track:
    - person
    - cat

record:
  enabled: True
  events:
    retain:
      default: 10
      mode: active_objects
    pre_capture: 5
    post_capture: 15

  sync_on_startup: True
  expire_interval: 60

# Optional: Configuration for the jpg snapshots written to the clips directory for each event
# NOTE: Can be overridden at the camera level
snapshots:
  # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
  enabled: True
  # Optional: save a clean PNG copy of the snapshot image (default: shown below)
  clean_copy: True
  # Optional: print a timestamp on the snapshots (default: shown below)
  timestamp: False
  # Optional: draw bounding box on the snapshots (default: shown below)
  bounding_box: False
  # Optional: crop the snapshot (default: shown below)
  crop: False
  # Optional: height to resize the snapshot to (default: original size)
  height: 175
  # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
  required_zones: []
  # Optional: Camera override for retention settings (default: global values)
  retain:
    # Required: Default retention days (default: shown below)
    default: 10
    # Optional: Per object retention days
    objects:
      person: 15
  # Optional: quality of the encoded jpeg, 0-100 (default: shown below)
  quality: 70

ui:
  # Optional: Set the default live mode for cameras in the UI (default: shown below)
  live_mode: mse
  # Optional: Set a timezone to use in the UI (default: use browser local time)
  # timezone: America/Denver
  # Optional: Use an experimental recordings / camera view UI (default: shown below)
  use_experimental: False
  # Optional: Set the time format used.
  # Options are browser, 12hour, or 24hour (default: shown below)
  time_format: browser
  # Optional: Set the date style for a specified length.
  # Options are: full, long, medium, short
  # Examples:
  #    short: 2/11/23
  #    medium: Feb 11, 2023
  #    full: Saturday, February 11, 2023
  # (default: shown below).
  date_style: short
  # Optional: Set the time style for a specified length.
  # Options are: full, long, medium, short
  # Examples:
  #    short: 8:14 PM
  #    medium: 8:15:22 PM
  #    full: 8:15:22 PM Mountain Standard Time
  # (default: shown below).
  time_style: medium
  # Optional: Ability to manually override the date / time styling to use strftime format
  # https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html
  # possible values are shown above (default: not set)
  strftime_fmt: "%Y/%m/%d %H:%M"

telemetry:
  # Optional: Enabled network interfaces for bandwidth stats monitoring (default: shown below)
  #network_interfaces:
  #  - eth
  #  - enp
  #  - eno
  #  - ens
  #  - wl
  #  - lo
  # Optional: Configure system stats
  stats:
    # Enable AMD GPU stats (default: shown below)
   # amd_gpu_stats: True
    # Enable Intel GPU stats (default: shown below)
    intel_gpu_stats: True
    # Enable network bandwidth stats monitoring for camera ffmpeg processes, go2rtc, and object detectors. (default: shown below)
    network_bandwidth: False
  # Optional: Enable the latest version outbound check (default: shown below)
  # NOTE: If you use the HomeAssistant integration, disabling this will prevent it from reporting new versions
  version_check: True

#WEB INTERFACE IS ON PORT 1984
go2rtc:
  streams:
    backyard:
      - rtsp://xxx

cameras:

  carriagehousefront: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://xxx/cam/realmonitor?channel=1&subtype=0 # <----- Update for your camera
          roles:
            - detect
    detect:
      enabled: True
    record:
      enabled: True
    objects:
      track:
        - person
        - cat
        - bird
        - dog
        - car
        - bear

***OTHERS REMOVED***

Relevant log output

Seeing lots of these

2023-09-15 15:38:03.607282597  [2023-09-15 15:38:03] frigate.record.maintainer      WARNING : Unable to keep up with recording segments in cache for attic2. Keeping the 5 most recent segments out of 8 and discarding the rest...
2023-09-15 15:38:03.607450479  [2023-09-15 15:38:03] frigate.record.maintainer      WARNING : Unable to keep up with recording segments in cache for backyardandpool1. Keeping the 5 most recent segments out of 6 and discarding the rest...
2023-09-15 15:38:03.608756112  [2023-09-15 15:38:03] frigate.record.maintainer      WARNING : Unable to keep up with recording segments in cache for backyardandpool2. Keeping the 5 most recent segments out of 7 and discarding the rest...
2023-09-15 15:38:03.609575258  [2023-09-15 15:38:03] frigate.record.maintainer      WARNING : Unable to keep up with recording segments in cache for basement_wireless. Keeping the 5 most recent segments out of 6 and discarding the rest...
2023-09-15 15:38:03.609634833  [2023-09-15 15:38:03] frigate.record.maintainer      WARNING : Unable to keep up with recording segments in cache for carriagehouseback. Keeping the 5 most recent segments out of 8 and discarding the rest...

Frigate stats

No response

Operating system

Other Linux

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

sync_on_startup: True

this should only be used if you have a reason to use it, this causes very high cpu usage like the docs explained

madasus commented 1 year ago

Here is the load average on the docker host for 24 hours prior to upgrade

image

madasus commented 1 year ago

@NickM-27 I just added that to test- still have high CPU when sync_on_start: False

NickM-27 commented 1 year ago

let's see a screenshot of the frigate system page with that option disabled

NickM-27 commented 1 year ago

oh wait just kidding I see what the problem is, you have not set your detect resolution, and in 0.13 frigate will auto detect the stream resolution and run on that. You should either set the detect resolution manually to 1280x720 or use a sub stream

madasus commented 1 year ago

That was it - thank you. Assumed it was something config related.

See a couple of other weird errors in the logs but i'm not even sure what camera is causing it

2023-09-15 15:58:29.472874440 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f3378474740] moov atom not found 2023-09-15 15:58:29.486681343 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f3378249800] moov atom not found 2023-09-15 15:58:29.498737277 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f3378205d00] moov atom not found 2023-09-15 15:58:29.572189209 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f337814cb80] moov atom not found 2023-09-15 15:58:29.647002029 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f33783c0040] moov atom not found 2023-09-15 15:58:29.647074705 [ERROR:0@13.209] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception: 2023-09-15 15:58:29.647077606 2023-09-15 15:58:29.647078754 OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern' 2023-09-15 15:58:29.647079490 2023-09-15 15:58:29.647080113 2023-09-15 15:58:29.672989837 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f33784a9f80] moov atom not found 2023-09-15 15:58:29.673064642 [ERROR:0@13.235] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception: 2023-09-15 15:58:29.673065659 2023-09-15 15:58:29.673066675 OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern' 2023-09-15 15:58:29.673067420 2023-09-15 15:58:29.673068021 2023-09-15 15:58:29.743236229 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f3378205d00] moov atom not found 2023-09-15 15:58:29.743333358 [ERROR:0@13.305] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception: 2023-09-15 15:58:29.743334236 2023-09-15 15:58:29.743335261 OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern' 2023-09-15 15:58:29.743335908

NickM-27 commented 1 year ago

that is just due to the camera resolution auto detection. Just set the detect resolution for each camera and it will be good to go

madasus commented 1 year ago

I set it in the main detect section

detect: max_disappeared: 500 width: 1280

Optional: height of the frame for the input with the detect role (default: shown below)

height: 720

Should that be ok?

I don't have anything under each camera

NickM-27 commented 1 year ago

I think that should be fine

madasus commented 1 year ago

thanks - i'll continue to monitor.

NickM-27 commented 1 year ago

Going to close this since the original issue was solved. Going to leave this pinned at the top of the issues board for now because I foresee other users running into the same thing