Local realtime person detection for RTSP cameras

:stuck_out_tongue:

There are no changes required for frigate to store clips on a network share. Many others are already doing this without an issue. You need to figure out how to mount your network share on the host and ensure that folder is mounted at /media/frigate in the container. This isnā€™t a frigate issue.

The thing is i am mounting, but after starting the addon it is overwriting the folder. And not writing to the network but to local again.
I understand what you are saying,I spended few hours to figure it out. Will try it next time.
I think the problem is hassos

The problem is hass.io addons. They do not allow you to mount your own folders. Your only options are the ones they already mount like /share or /media, etc. You will have to use one of those. If you want to put it somewhere else in the filesystem you will need to make a bind mount as a subfolder of one of those folders and tell frigate to store the clips there.

Yeah, but the thing is that even in /media, when i mount and turn on addon afterwards, it still use its own local folder (overwriten/created) and not the network folderā€¦ I will try to go deep in to the hole of the docker images to try and figure it out :open_mouth:

What do you think would be easier:

1.You might make some changes to the addon so it is possible to mount network share from frigate.yml.
I can post issue tracker to github

2.If i connect to your docker addon frigate, mount the network share from the inside of the container and change the const.py to the network share folder directly and dont go through host filesystem.
Or mount through docker compose on start?

What is more likely to be better solution?

Thank you <3

As scstraus explained to you, the limitation is not from Frigate side but instead from HassOS. Itā€™s not up to Blake to wake up and implement something that itā€™s applicable only to one use case scenario. The rest of the community is very happy how Frigate working. I was in the same boat as you and have Frigate running in docker on my Synology Nas and HassOS running in Synologyā€™s VMM. As well in the Docs for Frigate it is not recommended to run Frigate on virtualization platform as it introduces lag.

1 Like

Dears, could anybody explain how to run Frigate container from blakeblackshear/frigate:stable-amd64nvidia image in HA with Nvidia GPU support? Iā€™m stuck. When I launch docker-compose I cannot figure out how to run it either separately or within Hass Add-on. Read authorā€™s entire manual with no luckā€¦

When I try to exec into container build with docker-compose (configuration is below):

version: '3.9'
services:
  frigate:
    container_name: frigate
    privileged: false # this may not be necessary for all setups
    restart: unless-stopped
    image: blakeblackshear/frigate:stable-amd64nvidia
    runtime: nvidia
    environment:
      - NVIDIA_VISIBLE_DEVICES="all"
      - NVIDIA_DRIVER_CAPABILITIES="compute,utility,video"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/max/frigate:/config/config.yml:ro
      - /media/frigate:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: "pass"

I see Container 1749725c9edf1f69612bb3049472502410cff6943e745c0cd73a3bc3a55c3db1 is restarting, wait until the container is running

Besides, somehow docker-compose does not publish ports to the host.
What is wrong?

I donā€™t think you listened to my advice about bind mounting. I donā€™t think I can help you further and this is definitely not a valid feature request, and I donā€™t think you will solve it by messing with the addon config. You can switch to the standard docker image.

I dont understand what do you mean about the advise. I did test the bind option in media. Still not working.
From what i know in standart docker you cant do it with HASSIO and standart container with nabucasa remote connection. I need to use that.
So from what i can see now i need to figure out how to mount the network share from the inside of the container.

I am also interested how to do it,please update if you have any info. Thx <3

I have been looking into ffmpeg hw acceleration on Rockchip platforms, eg RK3399 soc used on Orangepi 4, Nanopi Neo4, M4, M4V2, NanoPC T4, Rock64 pro, Pinebook pro, Firefly RK3399, Rock Pi4a/b/c OR RK3288 / RK3388 used on Tinkerboard / S, Rock64, Nanopi Neo3/R2S and a few others

Rockchip has a powerful VPU on these SOCā€™s, can decode 4K at 60fps with no stuttering - I have had success in compiling ffmpeg with RKMPP support which is their API. The results were pretty dramatic on my NanoPC T4. I grabbed some footage from one of my cams to do a benchmark with some footage grabbed from my can 720p:

ffmpeg  -vcodec h264_rkmpp -i test.mp4  -f null - -benchmark
frame= 2046 fps=457 q=-0.0 Lsize=N/A time=00:03:24.60 bitrate=N/A speed=45.7x
video:1071kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=1.430s stime=1.812s rtime=4.500s
bench: maxrss=23424kB

ffmpeg   -i test.mp4  -f null - -benchmark
frame= 2046 fps=303 q=-0.0 Lsize=N/A time=00:03:24.60 bitrate=N/A speed=30.3x
video:1071kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=23.998s stime=2.373s rtime=6.769s
bench: maxrss=45328kB

User CPU time is 1.430 seconds for accelerated Vs 23.998 seconds for using CPU. The real time is 4.5 seconds vs 6.769s. FPS 457 vs 303. The most dramatic change is the CPU use. I will see how this scales with multiple cams in frigate, I plan to have three cams, two running currently

There are supposed to be other ways to access HW acceleration using v4l vaapi vdpau etc on my system rkmpp was the only one that I could get to work. I suspect other aarch64 platform vendors like Amlogic and Allwinner have similar hardware acceleration as these things are commonly used in kodi tv boxes. With my NanoPC T4 RK3399 platform you have to choose between legacy kernel supplied by vendor which is usually quite old but has HW acceleration, or latest mainline kernel that may not have all the acceleration ported to it. Kodi & Armbian forums are a good place to look
I have forked frigate and am currently building the docker images to try it out fully with frigate. I copied Dockerfile to a new one with the added support+dependencies. The are a few files in /dev that need to be available in the container too.
BTW the Google Coral USB TPU is in stock again on okdo.com, though I could move my ssd from the m.2 slot to USB3 port and get the B+M key one for cheaper, I think it will fit, I think my m.2 is M key?

Finally - Thanks for this great project, Iā€™ve had a few abortive attempts in setting up a system for my cams. I knew that recognition was needed, with real time alerts. Itā€™s no good having footage of someone stealing your stuff hours later after youā€™ve noticed a break in. Police will do nothing. What kickstarted me again was my neighbour coming round to ask if my cam was working since he had Ā£5K of bikes stolen. Sadly I had to tell him no. Then I found frigate. I am getting alerting via telegram with a snapshot which is great

1 Like

Hey, any idea why I would get so many triggers of this automation which uses the json trigger recommended in the docs when the same sensor only was triggered 3 times? Am I doing this wrong?

This automation:

- id: someone_through_gate
  alias: someone_through_gate
  initial_state: 'true'
  mode: single
  trigger:
    platform: mqtt
    topic: frigate/events
  condition:
    - "{{ trigger.payload_json['after']['label'] == 'person' }}"
    - "{{ 'inside_gate' in trigger.payload_json['after']['entered_zones'] }}"
  action:
    - choose:
        - conditions:
            - condition: state
              entity_id: device_tracker.sean_s_iphone_12
              state: 'home'
          sequence:
            service: notify.mobile_app_sean_s_iphone_12
            data_template:
              title: "Person Coming Through Gate"
              message: "Looks like someone is going to or coming from the front gate to the front door"
              data:
                attachment:
                  url: !secret frigate_image_url
                  content-type: jpg
                  hide-thumbnail: false
                clickAction: "/lovelace/8"
    - choose:
        - conditions:
            - condition: state
              entity_id: device_tracker.alena_s_iphone
              state: 'home'
          sequence:
            service: notify.mobile_app_alena_s_iphone
            data_template:
              title: "Person Coming Through Gate"
              message: "Looks like someone is going to or coming from the front gate to the front door"
              data:
                attachment:
                  url: !secret frigate_image_url
                  content-type: jpg
                  hide-thumbnail: false
                clickAction: "/lovelace/8"
    - choose:
        - conditions:
            - condition: state
              entity_id: device_tracker.sean_s_iphone_12
              state: 'home'
          sequence:
            - service: mqtt.publish
              data:
                topic: !secret genesys_5490_notify_topic
                payload: !secret genesys_5490_someone_through_gate_notification
    - delay:
        seconds: 11

Was triggered this many times:


When the same event only produced 3 hits on the sensor:

When Frigate finds a better snapshot of the tracked object or when a zone change occurs, it will publish a message with the same id. Maybe thatā€™s whatā€™s happening in your case?

Iā€™ve actually found it easier to base some of my automations off of the binary sensor to achieve the behavior Iā€™m looking for. A couple others still use the template triggers, though.

1 Like

Add this condition to only send when itā€™s a new event.

condition: '{{ trigger.payload_json["type"] == "new" }}'
2 Likes

Iā€™ve switched to unraid, where on earth do i place the config file? Never used unraid beforeā€¦

WTF? :open_mouth:

21-03-21 06:11:15 WARNING (MainThread) [supervisor.addons.validate] Add-on have full device access, and selective device access in the configuration. Please report this to the maintainer of Frigate NVR

21-03-21 06:11:15 WARNING (MainThread) [supervisor.addons.validate] Add-on have full device access, and selective device access in the configuration. Please report this to the maintainer of Frigate NVR

Protection mode
Blocks elevated system access from the add-on
is ON

Ok so Frigate works well on Unraid using coral pci but BlueIris in a win10 vm is horrible. Itā€™s like I can get one working but not both on the same pc :slight_smile:

So now back to using win10 desktop and Frigate in docker but still canā€™t get the edge tpu pci to show up in the Frigate container.

This is my cli:

frigate | Process detector:coral_pci:

frigate | Traceback (most recent call last):

frigate | File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 152, in load_delegate

frigate | delegate = Delegate(library, options)

frigate | File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 111, in __init__

frigate | raise ValueError(capture.message)

frigate | ValueError

frigate |

frigate | During handling of the above exception, another exception occurred:

frigate |

frigate | Traceback (most recent call last):

frigate | File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap

frigate | self.run()

frigate | File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run

frigate | self._target(*self._args, **self._kwargs)

frigate | File "/opt/frigate/frigate/edgetpu.py", line 124, in run_detector

frigate | object_detector = LocalObjectDetector(tf_device=tf_device, num_threads=num_threads)

frigate | File "/opt/frigate/frigate/edgetpu.py", line 63, in __init__

frigate | edge_tpu_delegate = load_delegate('libedgetpu.so.1.0', device_config)

frigate | File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 154, in load_delegate

frigate | raise ValueError('Failed to load delegate from {}\n{}'.format(

frigate | ValueError: Failed to load delegate from libedgetpu.so.1.0

Thank you, trying this out now. Let me ask, is there some reference where they describe these things like ā€œtypeā€ and ā€œafterā€? Iā€™ve been trying to make sense of some of this stuff but canā€™t really find a reference which explains it well.

1 Like

This follows on from @bremby, because am having a similar problem.
I think I understand the documents!

This works for me
http://homeassistant.local:5000/clips/front-1616362444.757426-08psgi.mp4

This does not, and I thought it should
http://homeassistant.local:8123/api/frigate/notifications/1616362444.757426-08psgi/front/clip.mp4
=> it returns 404: not found

I get the same response through the nabu.casa external URL.