Local realtime person detection for RTSP cameras

Hey guys, new user – I was running stable with five cams on a i7 with Google Coral. Seems I can only run frigate for 8 hours or so before it stops detecting anything and logs this message:

2020-04-16T21:46:38.508194704Z /arrow/cpp/src/plasma/store.cc:738: Disconnecting client on fd 6
2020-04-16T21:46:38.499404626Z Detection appears to be stuck. Restarting detection process
2020-04-17T01:49:22.668015792Z /arrow/cpp/src/plasma/store.cc:738: Disconnecting client on fd 6
2020-04-17T01:49:22.643717857Z Detection appears to be stuck. Restarting detection process

Screenshot from 2020-04-17 08-45-27 Screenshot from 2020-04-17 08-45-14

I moved to 0.5.1-RC2 and will see how stable it is – it is absolutely spewing out logs about the plasma store such as:

/arrow/cpp/src/plasma/eviction_policy.cc:134: There is not enough space to create this object, so evicting 13 objects to free up 80880384 bytes. The number of bytes in use (before this eviction) is 395718144.

Full docker logs:
https://hastebin.com/upixivivav.sql

Docker-compose:
https://hastebin.com/unazawabef.rb

Frigate config:
https://hastebin.com/aqohenehop.http

I assume the plasma messages are normal and just extra debugging in the RC?

This is know problem, majority (if not all) are having same issue with 05.x versions.
I’m currently restarting frigate in cron every 4 hours, until issue get’s sorted out.

1 Like

Afternoon Everyone,
I’m trying to add this to unraid, I THINK I’ve managed to set it up correctly, however when I try and run the docker i get the following errors:

TypeError: 'list' object is not a mapping
Traceback (most recent call last):
On connect called
File "detect_objects.py", line 134, in <module>
main()
File "detect_objects.py", line 79, in main
cameras[name] = Camera(name, FFMPEG_DEFAULT_CONFIG, GLOBAL_OBJECT_CONFIG, config, prepped_frame_queue, client, MQTT_TOPIC_PREFIX)
File "/opt/frigate/frigate/video.py", line 131, in __init__
self.regions = self.config['regions']
KeyError: 'regions'

my config file is as follows:

web_port: 5000

mqtt:
  host: 192.168.12.201
  topic_prefix: homeassistant
  user: 'homeassistant'
  password: 'MyMQTT Password'

objects:
  track:
    - person
    - car
    - truck
  filters:
    person:
      min_area: 5000
      max_area: 100000
      threshold: 0.5

cameras:
  back:
    ffmpeg:

      input: rtsp://USERNAME:[email protected]:8554/Streaming
#    regions:
#      - size: 720
#        x_offset: 0
#        y_offset: 0
#      - size: 12800
#        x_offset: 0
#        y_offset: 0
      input: rtsp://USERNAME:[email protected]:8554/unicast
      input: rtsp://USERNAME:[email protected]:8554/unicast
      input: rtsp://USERNAME:[email protected]:8554/unicast

    height: 1280
    width: 720

    take_frame: 1

    fps: 10

    snapshots:
      show_timestamp: True

Are there plans to create a pre-made docker template for community applications on unraid?
After adding:the following below the camera feeds:

    regions:
      - size: 1280
        x_offset: 0
        y_offset: 0

I’m getting the following error in the log:

On connect called
[mp3 @ 0x162e2e0] Header missing
Traceback (most recent call last):
File "detect_objects.py", line 134, in <module>
main()
File "detect_objects.py", line 79, in main
cameras[name] = Camera(name, FFMPEG_DEFAULT_CONFIG, GLOBAL_OBJECT_CONFIG, config, prepped_frame_queue, client, MQTT_TOPIC_PREFIX)
File "/opt/frigate/frigate/video.py", line 165, in __init__
merged_objects_config[obj] = {**global_objects_config.get(obj,{}), **camera_objects_config.get(obj, {}), **region_objects.get(obj, {})}
TypeError: 'list' object is not a mapping

You think i can run decently on a Celeron powered Intel NUC? I only have one camera…

Just published 0.5.1-rc3, which I hope will resolve the issues with the plasma store filling up. Here is the change log:

  • Improve cleanup of frame cache in plasma store
  • Add some debugging to see which frame each process is working on
  • Skip frames in the capture process if the detection process is falling behind

There a few property name changes in /debug/stats, so those with dashboards will need to update accordingly. Mainly, the fps property for each camera is now called camera_fps to differentiate it from the other related properties.

3 Likes

If you have a Coral and use hardware acceleration to decode the video stream, you should be able to handle several cameras.

Hi @blakeblackshear Any ideas where i might be going wrong in my configuration?
Thanks

Looks like you are trying to run the latest tag, which is actually an old version. I have removed the tag from docker hub as it keeps creating confusion. I would recommend trying 0.4.0 or 0.5.1-rc3. In addition, you have multiple inputs specified for a single camera. If you have additional cameras, you need to add them as separate cameras. The example config has one camera named back configured. No need to configure regions.

1 Like

Thankyou @blakeblackshear I’ve got my repostory set to
</s> <s>blakeblackshear/frigate</s> <s>
Out of interest do you have any plans on creating a premade unraid docker via community applications?

Do you have an example of how i would configure multiple cameras please?
all of my cameras are rtsp.

I’ve got it downloaded and it’s now running, the webconsole shows me

Frigate is running. Alive and healthy!

Although still not sure how to add multiple cameras.

I think I have multiple cameras connected now.

How can I see a live feed of what frigate is processing?

frigate seems to be stopping almost immediately after starting:

/arrow/cpp/src/plasma/store.cc:1226: Allowing the Plasma store to use up to 0.4GB of memory.
/arrow/cpp/src/plasma/store.cc:1253: Starting object store with directory /dev/shm and huge page support disabled
/arrow/cpp/src/plasma/store.cc:1270: System memory request exceeds memory available in /dev/shm. The request is for 400000000 bytes, and the amount available is 60397977 bytes. You may be able to free up space by deleting files in /dev/shm. If you are inside a Docker container, you may need to pass an argument with the flag '--shm-size' to 'docker run'.
Traceback (most recent call last):
File "detect_objects.py", line 246, in <module>
main()
File "detect_objects.py", line 148, in main
'fps': mp.Value('d', float(config['fps'])),
KeyError: 'fps'

Sorry, I’ve managed to sort out the memory error, now just getting this error:

On connect called
/arrow/cpp/src/plasma/store.cc:1226: Allowing the Plasma store to use up to 0.4GB of memory.
/arrow/cpp/src/plasma/store.cc:1253: Starting object store with directory /dev/shm and huge page support disabled
Traceback (most recent call last):
File "detect_objects.py", line 246, in <module>
main()
File "detect_objects.py", line 148, in main
'fps': mp.Value('d', float(config['fps'])),
KeyError: 'fps'

Same issue present when running version 0.5.0-rc3 and rc4

All running now. it seems that fps has to be defined for each camera at the top level.

1 Like

Thanks for the new version. Is this one fine with the Wyze RTSP feed? I have a Wyze cam that I want to enable RTSP on and start processing through Frigate.

I’ve had issues with all previous versions.
I have a couple of automation that restarts the container
1: when the fps drops to low for 5 minutes
2: when the ffmpeg_pid goes above 200 (which means the PID has restarted at least a few times)

Sometime it lasts for several hours but sometime it restarts several times in a 30 minutes period.

I’ve updated to rc3 and disabled my automations, so I’ll let you know my experience.

edit:
It’s been about 45 minutes and it has restarted several time and it’s currently at ffmpeg_pid: 1231
however the feed seems to be resuming successfully.

Premade unraid docker via community applications would be a win (for me and all the Unraid users)

While we’re making a wishlist, howabout a premade one for synology with hw accel :-)?

What are you guys looking for?
I don’t think there is anything specific for Synology (and possibly Unraid).
I have a Synology and I ran the Docker command to pull it down.
Once that was done, I created the config file (which is specific to each user) and then the HASS configs.

The hw accel options don’t seem to work on synology.

Are you referring to the Coral or something else?

edit:
is this what you are referring to? hwaccel_args
Does this do more than what the Coral provides?
If so, what is it supposed to leverage for the acceleration?

Yes that’s what I’m talking about.

It’s used for a different purpose than the coral. It’s for the processing that happens before the images are sent to the Coral, to have your GPU do it instead of your CPU.

How would I know whether it’s working or not?

Here’s the ffmpeg used (as viewed from within the container)

ffmpeg -loglevel verbose -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -vsync drop -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://user:[email protected]/live -f rawvideo -pix_fmt rgb24 pipe:

Thank you but when I do this rotation my resulting vertical image is cropped and has extra black on the sides to make it a landscape output. doorway doorway-2

I think you want your output args to be:

  output_args:
    - -vf
    - "transpose=1"
    - -f
    - rawvideo
    - -pix_fmt
    - rgb24
1 Like