Local realtime person detection for RTSP cameras

I just had a similar experience, with the following error:

frigate.object_processing      WARNING : Unable to create jpg because frame 1613016818.360265 is not in the cache
frigate.object_processing      WARNING : Unable to create jpg because frame 1613016818.360265 is not in the cache
Exception in thread detected_frames_processor:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/opt/frigate/frigate/object_processing.py", line 529, in run
    camera_state.update(frame_time, current_tracked_objects, motion_boxes, regions)
  File "/opt/frigate/frigate/object_processing.py", line 367, in update
    c(self.name, removed_obj, frame_time)
  File "/opt/frigate/frigate/object_processing.py", line 465, in end
    j.write(jpg_bytes)
TypeError: a bytes-like object is required, not 'NoneType'

Goodness, I just noticed that Home Assistant has updated and everythingā€™s screwed! Looks like Iā€™ll need to update a few things.

the new 800 has only h.265

1 Like

i have BlueIris in the middle.
C800 ->BI-> Frigate ā€¦ this works as well for view clips

streaming with the new C800 directly to frigate works but as already explained the browser ist not able to decode it.

@TobiasGJ

Good to know! I actually have a computer with BI that I donā€™t use. Does this workaround introduce any significant delay to the stream? How many cameras are you running this way?

@akifbayram

Just like Tobias said the new version only has h.265(+). A benefit of this version is that it also includes a microphone, which in my use case, is an improvement. The design is different, but apart from that, it seems to have the same specs as the previous version.

@paulstronaut

Do you know what the args would be like? Iā€™ve been digging around on the ffmpeg website without getting any wiser.

It would be convenient if everything could be done using the same machine, without a separate windows machine for BI.

1 Like

Hi,

Iā€™m trying to do the same but just get the frigate error ā€œffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structuresā€ā€¦ the zm streams work fine in my browser but suspect its my ffmpeg settingsā€¦ can you share yours please?

I just upgraded from 0.6.0 to 0.8.1 and have everything up and running (after redoing my config based on the docs). Everything is working properly (thank you for the great component!) but I canā€™t seem to get snapshot notifications to work. I have tried the example in the docs but no snapshot ever gets sent. I am running hass & frigate in docker. I checked the frigate/events and i see the messages. I also checked the clips folder, and there are jpgā€™s in there, so I am not sure where the hang up is. I use Duckdns and LE for my public hass address. Any thoughts on where I could start to look.

I would suggest opening an issue on GH and including your notification yaml.

The default args are listed here.

These output_args may work:

  output_args:
    # Optional: output args for record streams (default: shown below)
    record: -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an
    # Optional: output args for clips streams (default: shown below)
    clips: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an
    # Optional: output args for rtmp streams (default: shown below)
    rtmp: -c:v libx264 -f flv

There are tons of options around quality, etc that can impact performance of the re-encode.

These are the input_args I use on Frigate 0.7.3 for the mjpeg Zoneminder cameras:

      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer
        - -flags
        - low_delay
        - -strict
        - experimental
        - -fflags
        - +genpts+discardcorrupt
        - -r
        - '3'
        - -use_wallclock_as_timestamps
        - '1'

You will need to adjust them for the other roles that are included in 0.8.x as well.

1 Like

Many many thanks for this, no idea how you figured out those params but its working a treat.

I wonder, have you noticed that in the frigate config the fps param no longer limits the frames when your taking the stream from zoneminder? I had it set to 5 and it worked when I was streaming from the camera but not when streaming from zoneminder

That worked, but my 10th gen i5 NUC CPU usage rose to 97% (normally around 4%).
It gave significant compression artefacts along lines in the image and when Iā€™m checking the properties for the clips it suggests they are 50fps. And also, the clips seem to be out of time, and filmed prior to me entering the ā€œsceneā€.

I donā€™t wanna take your time, you are already giving us more support than expected, but do you think it is reasonable to acheive what Iā€™m trying here? Eventually I would like to have five or so of these cameras.

Yeah, itā€™s likely because itā€™s an mjpeg stream without keyframing or any of the nice things that RTSP has. If you limit the framerate via the ZM url (as I do with &maxfps=3) and in the Frigate config as well, everything seems to play nicely in my experience.

1 Like

If it was me I would just get cameras that support h264 instead. You can probably tune the conversion to reduce load and may even be able to get hwaccel to work for encoding again. That should lower the CPU required, but itā€™s just unnecessary overhead. Iā€™m not sure how low you can get it, but Iā€™m sure you can do much much better. You can use the generated ffmpeg command from frigate and run it anywhere for quicker testing of different options.

1 Like

ah Iā€™d not thought of that cheersā€¦ the only other thing Iā€™ve noticed is the clips frigate now writes donā€™t seem to be playableā€¦ guessing Iā€™ve got to figure out some new output_args now too

Yeah, just make sure that everything is being converted to h264 and Frigate should work as intended. You can also get a shell into the Frigate Docker container and run ffmpeg directly to try various arguments. Iā€™ve found thatā€™s easier to debug and figure out what works than restarting Frigate with new args every time I want to try one.

Help me. Instance only one.

On connect called


    main()


  File "detect_objects.py", line 196, in main


    ffmpeg_input = get_ffmpeg_input(ffmpeg['input'])


KeyError: 'input'
mqtt:
  host: 192.168.88.37
cameras:
  frontdoor:
    ffmpeg:
      inputs:
        - path: http://192.168.88.37:8585/zm/cgi-bin/nph-zms?mode=jpeg&monitor=2&scale=0&maxfps=5
          roles:
            - detect
            - rtmp
    width: 704
    height: 576
    fps: 5

Looks like you are using an old version of Frigate. Your config file is for 0.8.x. Upgrade Frigate to 0.8.x and your config should work.

1 Like

docker version 0.8.1-amd64

Cooldown Period:
Question: is it possible to configure a cooldown period in the config?

Means if a motion was happened, the system wait e.g. for 1 minute to accept new motions.

Hi,
I recently started seeing this error with frigate failing to start:

 * Starting nginx nginx
   ...done.
Error parsing config: 'mqtt'

even when i try it with following config:

detectors:
  coral:
    type: edgetpu
    device: 'usb:0'
mqtt:
  host: 192.168.86.99
  topic_prefix: frigate
  user: mqtt_username
  password: pwd
ffmpeg: {}
cameras: {}

Im on frigate beta v 1.8 and HA 2021.1.5

It worked fine and suddenly stopped working without me touching it and started throwing the above error. Just wonder if anyone had similar issues or can point out in direction of fixing it please?

Thanks,
Alex