Local realtime person detection for RTSP cameras

I’m assuming you’re running Home Assistant OS/Supervised. If so, this is a known issue. HA made some underlying supervisor changes that broke Frigate and other integrations. You need to upgrade Frigate and the integration to the latest version for the fixes (the stable branch is more up-to-date than the beta). After you upgrade, your Frigate config file will have to be named frigate.yml and placed in the HA config directory.

I achieve this right now with Home Assistant so that I’m not notified of new objects every time Frigate sends new info about a detection. You can set a 00:01:00 delay at the end of your automation (in automation mode Single) so that it only runs once per minute.

… that’s an idea…
thanks…

perfect, that worked very well. Thanks a mil!

I have the same issue, please share if you find a solution.

You will need to convert mjpeg to h264 video in order for Frigate’s clips feature to work. The default output_args just copies the video codec instead of converting it because it assumes an RTSP h264 input feed instead of an mjpeg feed that Zoneminder outputs.

You could convert it on input or output. As Blake mentioned a few posts ago, these args may work. Notice the -c:v libx264 (modified args) instead of -c copy (default args):

You will likely notice increased CPU utilization as the conversion is done by ffmpeg. For 0.8.x and beyond, the better solution is to connect your cameras to Frigate directly rather than using a Zoneminder camera.

Ok thank, I will try with that. Dont know how I missed Blakes post. Yes I know rtsp is prefered, actully I dont use zoneminder, I use the mjpeg stream directly from the camera. It’s a old arecont vision camera (av8365dn), it do have rtsp/x264, but when I use it the camera will hang after a while. Very frustrating. The mjpeg stream works fine however.

Hi,

When i change it to the subtype 1 i get green lines in the screen, and the stream is multiplied several times.
This specific camera doesnt have a webinterface so i cannot check the settings.

Thanks anyway.

  • Dion

That’s because the frame size is different, you need to put
width: 640 height: 480 fps: 5
on your camera settings
:wink:

Yes that worked thanks!

Now i just need to know how i can get the detection frames on the clips in the media browser. Like in the example and then i am all good. Just need to wait on my coral arrival.

Just got my coral and am having hours of harmless fun setting things up.

I have two issues I’d appreciate a little help on
1 - getting hw acceleration to work
2 - getting recordings to work

I am running Frigate in Docker on a Pi4 32 bit booted off an SSD. (My HA instance is completely separate, on a NUC under Docker, with MQTT and network communications working just fine.) I’m just using one camera at the moment - a UniifG3 Flex (called gate), which produces an rtsp stream from Unifi Protect.

My starting point is

ffmpeg:
  global_args: -hide_banner -loglevel warning
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
  output_args:
    detect: -f rawvideo -pix_fmt yuv420p
    record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an
    clips: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an

If I try the recommended settings, as per the manual ie adding

  hwaccel_args:
    - -c:v
    - h264_mmal

then I get the following error:


watchdog.gate                  INFO    : No frames received from gate in 20 seconds. Exiting ffmpeg...


watchdog.gate                  INFO    : Waiting for ffmpeg to exit gracefully...


frigate.video                  INFO    : gate: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures


frigate.video                  INFO    : gate: ffmpeg process is not running. exiting capture thread...

followed by multiple ffmpeg errors.

I have not managed to get recordings to work at all.

Anyone have any suggestions about solving my two issues?

What kind of camera is it? If possible, make sure it’s sending Frigate RTSP h264 video. If it’s sending rtmp or mjpeg, you’ll need to adjust the ffmpeg args if you cannot adjust the format of the camera output.

@blakeblackshear i opened an issue on github about the addon, now i get 2 images on docker, 1.10 and 0.8.1. The addon is using 1.10 one but i am unable to delete 0.8.1 as it say that has a child images being used. Both are 845 MB so the old image is wasting space on my snapshots

Hello @hawkeye217

As I mentioned, it’s a Ubiquiti G3 Flex streaming through Unifi’s Protect packge. As I’m sure you don’t carry around every camera in your head, this is what VLC says the stream is:
Screenshot 2021-02-12 at 15.23.32

It certainly seems to be h264.

You could try changing your ffmpeg global_args to:

global_args: -hide_banner -loglevel debug

And then change the frigate log level to

logger:
  default: debug

And see what ffmpeg is telling you then.

Here is the (start of) the error stream:

frigate.edgetpu                INFO    : TPU found

frigate.app                    INFO    : Capture process started for gate: 37

frigate.mqtt                   DEBUG   : on_clips_toggle: frigate/gate/clips/set ON

frigate.mqtt                   INFO    : Turning on clips for gate via mqtt

frigate.mqtt                   DEBUG   : on_snapshots_toggle: frigate/gate/snapshots/set ON

frigate.mqtt                   INFO    : Turning on snapshots for gate via mqtt

watchdog.gate                  INFO    : No frames received from gate in 20 seconds. Exiting ffmpeg...

watchdog.gate                  INFO    : Waiting for ffmpeg to exit gracefully...

frigate.video                  INFO    : gate: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures

frigate.video                  INFO    : gate: ffmpeg sent a broken frame. read of closed file

frigate.video                  INFO    : gate: ffmpeg sent a broken frame. read of closed file

frigate.video                  INFO    : gate: ffmpeg process is not running. exiting capture thread...

ffmpeg.gate.detect             ERROR   : Error while decoding stream #0:1: Unknown error occurred

ffmpeg.gate.detect             ERROR   : cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)

ffmpeg.gate.detect             ERROR   :     Last message repeated 4 times

ffmpeg.gate.detect             ERROR   : [h264_mmal @ 0x1be7710] MMAL error 2 on control port

ffmpeg.gate.detect             ERROR   :     Last message repeated 5 times

ffmpeg.gate.detect             ERROR   : [h264_mmal @ 0x1be7710] Did not get output frame from MMAL.

ffmpeg.gate.detect             ERROR   : Error while decoding stream #0:1: Unknown error occurred

ffmpeg.gate.detect             ERROR   : cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)

ffmpeg.gate.detect             ERROR   : [h264_mmal @ 0x1be7710] MMAL error 2 on control port

ffmpeg.gate.detect             ERROR   :     Last message repeated 4 times

ffmpeg.gate.detect             ERROR   : [h264_mmal @ 0x1be7710] Did not get output frame from MMAL.

ffmpeg.gate.detect             ERROR   : Error while decoding stream #0:1: Unknown error occurred

(this is with the vanilla hwaccel_args)

Might want to try setting gpu_mem=256 in your /boot/config.txt… Other than that, not sure what the issue could be. I have Frigate running on an i7 and a Pi4 64 bit and I use the respective hwaccel options for each platform without an issue.

1 Like

Thanks @hawkeye217. I will try that and report back.

Yay, that sorted out the problem. Now no errors and no CPU being maxed out. Thanks! (One for the Troubleshooting and FAQ section, maybe?)

Any ideas on problem #2 - no clips? (I just spotted that I had set tmpfs_cache_size in config in spite of setting a temps in Docker, but it seems unlikely that was the killer issue.)

Question…
How to increase size of available size of clips directory when using docker?
Got an error. Running du -sh gives me a total size of 6.5G, while available disk space is over 100G …