Local realtime person detection for RTSP cameras

It worked for me

1 Like

Hi all.
Frigate records when person is moving, when person stops, after few seconds the recording of person stops as well (bounding box dissapears). How to continue the recording, despite that person is not moving anymore?

Thanks.

Stationary Objects

Been using frigate since this thread was started. It had NEVER properly classified any ā€œanimalā€.

Checked several time over past year to make sure labelmap.txt was being picked up and in correct spot. Thought it was. Learned today default location is /labelmap.txt and not /config/labelmap.txt. :man_facepalming: Added below to move default location and everything finally working. Just adding here in case someone else is as idiotic as me

model:
  labelmap_path: /config/labelmap.txt

I could bind mount this in docker but prefer to keep it is same folder with config. I change my labelmap to make all animal types ā€œanimalā€ So dog is ā€œanimalā€ and giraffe is ā€œanimalā€. Since i only detect ā€œanimalā€ the other types were missed

I figured it out it would be under global config so not indented. I am actually struggling alot with how some things can be global config, some things can be under camera, and I suppose somethings can be overidden under the camera

Now anybody point me to a tutorial to properly understand go2rtc,webrtc and how they work with home assistant? I am running frigate in docker(I could not passthrough the google coral to HASSOS VM), Frigate integration, and Frigate proxy addon.

Ugh first set up with frigate I am really having some issues nailing down the yaml and it seems like there is maybe a few versions of the documentation.

I am running ghcr.io/blakeblackshear/frigate:0.12.0-beta10 and I am just not getting the go2rtc streaming working. What the heck am I doing wrong here.

#frigate sample config.yml
mqtt:
  # Required: host name
  host: 10.0.0.249
  # Optional: port (default: shown below)
  port: 1883
  # Optional: topic prefix (default: shown below)
  # WARNING: must be unique if you are running multiple instances
  topic_prefix: frigate
  # Optional: client id (default: shown below)
  # WARNING: must be unique if you are running multiple instances
  client_id: frigate
  # Optional: user
  user: mqtt
  # Optional: 
  # NOTE: Environment variables that begin with 'FRIGATE_' may be referenced in {}.
  #       eg. password: '{FRIGATE_MQTT_PASSWORD}'
  password: redacted
  # Optional: interval in seconds for publishing stats (default: shown below)
  stats_interval: 60
 


detectors:
  # cpu1:
    # type: cpu
  # cpu2:
    # type: cpu
  coral:
    type: edgetpu
    device: usb

cameras:
  frontdoor: # <------ Name the camera
    objects:
      track:
        - person
        - car
        - bicycle
        - motorcycle
        - cup
      filters:
        car:
          mask:
            - 0,806,54,816,166,829,308,828,562,760,694,703,768,693,768,1024,0,1024       
    ffmpeg:
      hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
 #     hwaccel_args: -c:v h264_qsv
      inputs:
        - path: rtsp:/redacted:[email protected]:554/Streaming/Channels/101 # <----- Update for your camera
          roles:
            - record
            - rtmp
        - path: rtsp:/redacted:[email protected]:554/Streaming/Channels/101
          roles:
            - detect
    rtmp:
      enabled: False # <-- RTMP should be disabled if your stream is not H264
    go2rtc:
      streams:
        frontdoor:
          - rtsp:/redacted:[email protected]:554/Streaming/Channels/101

    detect:
      width: 768 # <---- update for your camera's resolution
      height: 1024 # <---- update for your camera's resolution
      fps: 5
      enabled: true
    motion:
      threshold: 25
      mask:
 #       - 0,473,0,488,176,488,176,473 substream
 #      - 53,1957,646,1951,648,1904,54,1905 fullstream
        - 28,982,277,982,277,955,25,955
    record:
      enabled: true
      retain:
        days: 2
        mode: motion
      events:
        retain:
          default: 10
    snapshots:
      enabled: true
          

getting:

Config Error:

Traceback (most recent call last):
  File "/opt/frigate/frigate/http.py", line 761, in config_save
    new_yaml = FrigateConfig.parse_raw(new_config)
  File "/opt/frigate/frigate/config.py", line 1077, in parse_raw
    return cls.parse_obj(config)
  File "pydantic/main.py", line 527, in pydantic.main.BaseModel.parse_obj
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for FrigateConfig
cameras -> frontdoor -> go2rtc
  extra fields not permitted (type=value_error.extra)
```**strong text**

go2rtc must be setup globally. use the guide in the docs Configuring go2rtc | Frigate

FYI this error tells you gortc is not in the right place.

It is a global only value. And then your other camera streams use gortc restreams so donā€™t need the url to the camera directly.

1 Like

I just passed this from the docs and got error:

go2rtc:
  streams:
    rtsp_cam: # <- for RTSP streams
      - rtsp://192.168.1.5:554/live0 # <- stream which supports video & aac audio
      - "ffmpeg:rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)
    http_cam: # <- for other streams
      - http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password # <- stream which supports video & aac audio
      - "ffmpeg:http_cam#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)

cameras:
  rtsp_cam:
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/rtsp_cam # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
  http_cam:
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/http_cam # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect

Property go2rtc is not allowed.yaml-schema: FrigateConfig(0)

View Problem (Alt+F8)

are you running 0.12?

image: blakeblackshear/frigate:0.12.0-beta2

at the moment

thatā€™s a very old version of the beta, and frigate is no longer being deployed on dockerhub

Yes I figured that out, also @crzynik .I had a heck of a time using the Original documentation, which is linked to in the Beta menu. I was trying to piece it together with google and peoples posts on github but Frigate continues to evolve quite quickly which is awesome. Then I found the documentation here https://deploy-preview-4055ā€“frigate-docs.netlify.app/ .

So I am a completely new user of frigate, I had been using Motion Eye before. With frigate comes some new concepts (to me) go2rtc and webrtc. I am starting to see the benefits of go2rtc,which has now been ā€œbundledā€ with frigate, as my cameras have only one stream or a substream thats 384x512. I am struggling to piece together how it all comes together in home assistant. I was hoping to find a tutorial that covers these but I havenā€™t so far. I think my goal is to get go2rtc to restream for a detection stream and to home assistant (maybe using webrtc??). I am using the integration and the addon frigate proxy. Any assistance/direction is appreciated.

Frigate 0.12 is now fully released and the stable docs now reflect 0.12. See the go2rtc tutorial here Configuring go2rtc | Frigate

2 Likes

If using docker, the addon proxy and home assistant integration does one still need to set up Webrtc as per the docs https://docs.frigate.video/configuration/live#webrtc-extra-configuration

What stream does the integration or the addon proxy pull into HA. I configured go2rtc like this which works for MSE in the Frigate page.

go2rtc:
  enabled: True
  streams:
    frontdoor:
      - "rtsp://redacted:[email protected]:554/Streaming/Channels/102/"

Should HA utilize the new stream set up in go2rtc. I have currently configured the substream in the above so I can figure out what I am seeing in Home assistant.

The integration will use the RTSP stream from go2rtc provided the name of the camera in both sections of the config is the same

lol thanks, now itā€™s working.

Tell me please. One of the cameras stopped working in Frigate.

2023-04-10 15:10:53.431563271  [2023-04-10 18:10:53] frigate.video                  ERROR   : camera_1: Unable to read frames from ffmpeg process.
2023-04-10 15:10:53.432104632  [2023-04-10 18:10:53] frigate.video                  ERROR   : camera_1: ffmpeg process is not running. exiting capture thread...
2023-04-10 15:11:00.780775066  [2023-04-10 18:11:00] watchdog.camera_1              ERROR   : Ffmpeg process crashed unexpectedly for camera_1.
2023-04-10 15:11:00.780850148  [2023-04-10 18:11:00] watchdog.camera_1              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2023-04-10 15:11:00.780965677  [2023-04-10 18:11:00] ffmpeg.camera_1.detect         ERROR   : [rtsp @ 0x564644ef6e40] method DESCRIBE failed: 401 Unauthorized
2023-04-10 15:11:00.780997434  [2023-04-10 18:11:00] ffmpeg.camera_1.detect         ERROR   : rtsp://*:*@192.168.1.62:554/user=admin&password=XXX%211&channel=1&stream=0.sdp?: Server returned 401 Unauthorized (authorization failed)

The code in yaml looks like this:

mqtt:
  host: 192.168.1.134
  user: Alexey
  password: Alexey!1
  
cameras:
  camera_1: # <------ Name the camera
    mqtt:
      crop: True
      height: 500
    rtmp:
      enabled: false
    ffmpeg:
      input_args: -rtsp_transport tcp
      inputs:
        - path: rtsp://root:[email protected]:554/user=admin&password=XXX&channel=1&stream=0.sdp? # <----- Update for your camera
          roles:
            - detect
            - rtmp
            - record
            - clips
    detect:
      width: 1280 # <---- update for your camera's resolution
      height: 720 # <---- update for your camera's resolution
      fps: 14
    objects:
      track:
        - person
        - bicycle
        - car
        - motorcycle
        - bird
        - cat
        - dog
      filters:
        person:
          min_score: 0.6 # min score for object to initiate tracking (default: 0.5
          threshold: 0.8 # min decimal percentage for tracked object's computed score to be considered a true positive (default: 0.7)
        car:
          threshold: 0.85
          min_score: 0.6
      mask:
        - 880,73,884,32,1280,26,1280,67
        - 112,175,556,134,554,327,123,360
    zones:
      parking:
        coordinates: 470,315,264,334,190,569,413,685,710,680,883,540,1236,525,1241,307,875,150,461,175
        objects:
          - car
    record:
      enabled: True
      retain:
        days: 3
        mode: motion
      events:
        pre_capture: 15
        post_capture: 15
        objects:
          - person
        retain:
            default: 10
            mode: motion

HI,

anyone can help me to understand how to configure Birdseye Restream, I read the documentation but I donā€™t understand how to do it

https://deploy-preview-4055ā€“frigate-docs.netlify.app/configuration/restream#birdseye-restream

Birdseye Restream
Birdseye RTSP restream can be enabled at birdseye -> restream and accessed at rtsp://<frigate_host>:8554/birdseye. Enabling the restream will cause birdseye to run 24/7 which may increase CPU usage somewhat.

This means at

birdseye:
  restream: True

see Configuration File | Frigate for a full config example

1 Like

Hi,

Iā€™m running Frigate container on raspberry

Raspberry Pi 4 Model B Rev 1.4
aarch64

as soon I add hwaccel arg the ffmeg stop to work.

cameras:
 camera1:
  ffmpeg:
    inputs:
    - path: rtsp://<user:password@IP>/videoMain
      hwaccel_args: preset-rpi-64-h264
      input_args: preset-rtsp-generic
      roles:
       - detect
2023-04-11 23:02:39.890394298  [2023-04-11 23:02:38] frigate. Video                  ERROR   : camera1: Unable to read frames from ffmpeg process.
2023-04-11 23:02:39.891043423  [2023-04-11 23:02:38] frigate.video                  ERROR   : camera1: ffmpeg process is not running. exiting capture thread...
2023-04-11 23:03:26.991838334  [2023-04-11 23:03:26] ffmpeg.camera1.detect          ERROR   : Guessed Channel Layout for Input Stream #0.1 : mono
2023-04-11 23:03:26.991841723  [2023-04-11 23:03:26] ffmpeg.camera1.detect          ERROR   : [h264_v4l2m2m @ 0x55c1bee610] Failed to find Size=2304x1536, fmt=NV12 in 1 frame size enums
2023-04-11 23:03:26.991844760  [2023-04-11 23:03:26] ffmpeg.camera1.detect          ERROR   : Error while opening decoder for input stream #0:0 : Invalid argument

any suggestions?