Local realtime person detection for RTSP cameras

Oh yes, I’m really blind. Before I could only see the timestamp_style setting , but now I see it under ui block as well. Thank you.

I keep getting cameras with this displayed:
image

When I click into the camera, the stream is working, but it breaks everywhere else (such as on Area cards) until I restart Frigate.

I have some errors in the go2rtc logs:

[INFO] Starting go2rtc...
2023-05-02 16:06:49.290807176  curl: (7) Failed to connect to 127.0.0.1 port 1984: Connection refused
2023-05-02 16:06:49.294740120  [ERROR] The go2rtc service is not responding to ping, restarting...
2023-05-02 16:06:49.424492204  [INFO] The go2rtc service exited with code 256 (by signal 15)

But I can’t find any errors specific to the camera(s) that are failing like this.

Share your config (but mask passwords) please

I made a quick and dirty script to restart frigate when a camera is down. Or actually when there is no ffmpeg process associated with the camera. It is best to solve the issue when it happens, but I also do not want my camera not recording anymore. More then once I found that my camera was showing “No frames have been received, check error logs”. Restarting frigate solved the issue.

mqtt:
  host: REDACTED
  port: 1883
  user: REDACTED
  password: REDACTED
detectors:
  coral:
    type: edgetpu
database:
  path: /config/frigate.db
detect:
  width: 1280
  height: 720
  fps: 5
  enabled: True
  max_disappeared: 25
  stationary:
    interval: 0
    threshold: 50
    max_frames:
      default: 3000
      objects:
        person: 1000

objects:
  track:
    - person
  filters:
    person:
      min_area: 5000
      max_area: 100000
      min_score: 0.5
      threshold: 0.75

motion:
  threshold: 25
  contour_area: 50
  delta_alpha: 0.2
  frame_alpha: 0.2
  frame_height: 50
  improve_contrast: False

record:
  enabled: True
  events:
    pre_capture: 5
    post_capture: 10
    objects:
      - person
      - dog
      - car
    required_zones: []
    retain:
      default: 30
      mode: active_objects
      objects:
        dog: 3
        car: 3

snapshots:
  enabled: False
  timestamp: False
  bounding_box: False
  crop: False
  required_zones: []
  retain:
    default: 30
    objects:
      dog: 3
      car: 7

live:
  height: 720
  quality: 31

timestamp_style:
  position: "tl"
  format: "%m/%d/%Y %H:%M:%S"
  color:
    red: 255
    green: 255
    blue: 255
  thickness: 2
  effect: solid
    
go2rtc:
  streams:
    drive:
      - rtsp://REDACTED:REDACTED@REDACTED:554/Preview_01_sub
    front_door:
      - rtsp://REDACTED:REDACTED@REDACTED/cam/realmonitor?channel=1&subtype=0
    front_yard:
      - rtsp://REDACTED:REDACTED@REDACTED:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
    back_yard:
      - rtsp://REDACTED:REDACTED@REDACTED:554/h264Preview_01_main
    patio:
      - rtsp://REDACTED:REDACTED@REDACTED:554/h264Preview_01_main
    atrium:
      - rtsp://REDACTED:REDACTED@REDACTED:554/ISAPI/Streaming/channels/102
    playroom:
      - rtsp://REDACTED:REDACTED@REDACTED:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
    living:
      - rtsp://REDACTED:REDACTED@REDACTED:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
    dining:
      - rtsp://REDACTED:REDACTED@REDACTED:554/h264Preview_01_main

cameras:
  drive:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/drive 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
      input_args:
        - '-avoid_negative_ts'
        - make_zero
        - '-fflags'
        - nobuffer
        - '-flags'
        - low_delay
        - '-strict'
        - experimental
        - '-fflags'
        - +genpts+discardcorrupt
        - '-use_wallclock_as_timestamps'
        - '1' 
    detect:
      width: 1536
      height: 576
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_door 
          input_args: preset-rtsp-restream
          roles:
            - detect
            - record
    detect:
      width: 1920
      height: 1080
  front_yard:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_yard 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
      input_args:
        - '-avoid_negative_ts'
        - make_zero
        - '-fflags'
        - nobuffer
        - '-flags'
        - low_delay
        - '-strict'
        - experimental
        - '-fflags'
        - +genpts+discardcorrupt
        - '-use_wallclock_as_timestamps'
        - '1' 
    detect:
      width: 1920
      height: 1088
  back_yard:
    ffmpeg: 
      inputs:
        - path: rtsp://127.0.0.1:8554/back_yard 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
      input_args:
        - '-avoid_negative_ts'
        - make_zero
        - '-fflags'
        - nobuffer
        - '-flags'
        - low_delay
        - '-strict'
        - experimental
        - '-fflags'
        - +genpts+discardcorrupt
        - '-use_wallclock_as_timestamps'
        - '1' 
    detect:
      width: 2560
      height: 1920
  patio:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/patio 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
      input_args:
        - '-avoid_negative_ts'
        - make_zero
        - '-fflags'
        - nobuffer
        - '-flags'
        - low_delay
        - '-strict'
        - experimental
        - '-fflags'
        - +genpts+discardcorrupt
        - '-use_wallclock_as_timestamps'
        - '1'
    detect:
      width: 640
      height: 480
  atrium:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/atrium 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
      output_args:
        record: -f segment -segment_time 10 -segment_format ts -reset_timestamps 1 -strftime 1 -c:v libx264
    detect:
      width: 2688
      height: 1520
  playroom:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/playroom 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    detect:
      width: 640
      height: 480
  living:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/living 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
      input_args:
        - '-avoid_negative_ts'
        - make_zero
        - '-fflags'
        - nobuffer
        - '-flags'
        - low_delay
        - '-strict'
        - experimental
        - '-fflags'
        - +genpts+discardcorrupt
        - '-use_wallclock_as_timestamps'
        - '1'
    detect:
      width: 2560
      height: 1440
  dining:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/dining 
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
    detect:
      width: 640
      height: 352

Small update in regards to this script, it can now copy a log file before restart. This way the log can be reviewed later while frigate, hopefully, comes back online with a fresh connection to your camera(s)

Anybody? I’m about to dump go2rtc because of this.

usually this happens because you are also running HA with the webrtc integration. You need to disable the webrtc integration, get frigate running, then re set up the webrtc integration pointing to frigate_ip:1984 (if you are running the integration, the webrtc integration will find it automatically)

Don’t believe I’m using that, absolutely no other camera stuff setup on my config. Gotta be done with go2rtc for now. Seems buggy as heck.

only thing standing out as different to mine is the extra input args you put in some cameras

Unfortunately, one camera that suffers this problem frequently has no input args at all (front_door).
It does appear that those that have intermittent network interruptions are the most prone to this occurring. Though I’ve removed all the input args, and continue to suffer this problem on more unreliable (wifi) cameras. I’m having to do away with go2rtc for these, disappointingly.

Hi, i want to detect person that come in the specific zone that i have defined. but the zone is not working the camera is detecting everything. can someone help me?
this is my config:

      required_zones:
        - oprit_huis
      enabled: true
      timestamp: true
      bounding_box: true
    objects:
      track:
        - car
        - person
    zones:
      oprit_huis:
        coordinates: 65,421,186,720,1053,720,1215,279,1203,223,771,99 

You need to make the zone required Zones | Frigate

1 Like
zones:
      oprit_huis:
        coordinates: 65,421,186,720,1053,720,1215,279,1203,223,771,99 
        objects:
          - person
1 Like

I started out with 2, then 4, then 6 (!) cameras on an HAOS raspberry-4, which was understandably struggling at 85% CPU… Working, but struggling all the same, it was an interesting learning curve. Mostly it was detecting movement well with some masks to reduce the load from wavy trees.

I’m now running an HAOS mini-PC with a coral stick and an SSD. It’s blistering along at 25% CPU with 6 cams and detecting people, dogs, cats, umbrellas and all sorts. Wonderful!

Don’t get me wrong, I love the raspberry, and I’ve another providing excellent service as a home security system with little or no video. Also, to clarify, the raspberry did well with a couple of cameras, no complaints, but with 6 I needed to move up a shelf.

Just fyi. here.

3 Likes

Hey boyz & grilz,
need assistance. I have a remote camera that sometimes glitches due to communication.
I have seen that when it glitches frigate see 0fps. Is it possible somehow to read the fps, so i can send some notification?

yes, just use the camera_fps sensor (it needs to be enabled)

Awesome, can you be so kind and provide me any link? <3 * i am not using integration just Addon

So i need the integration? :frowning: