frigate
frigate copied to clipboard
[Config Support]: Speed Detection/lights on delay
Describe the problem you are having
Hello,
I would use my Camera to detect a Person and lights on. It work but with a delay of 3-5 seconds. I have make a automation in Nodered. Can anyone help me please?
Version
0.11.1
Frigate config file
mqtt:
host: core-mosquitto
user: mqtt
password:
port: 1883
database:
path: /media/frigate/frigate.db
detectors:
coral:
type: edgetpu
device: usb
birdseye:
enabled: True
mode: continuous
cameras:
Kamera_HWR:
ffmpeg:
inputs:
- path: rtsp://192.168.31.230:554/stream0?username=admin&password=E10ADC3949BA59ABBE56E057F20F883E
roles:
- detect
- clips
- record
detect:
width: 720
height: 480
fps: 10
objects:
track:
- person
- car
snapshots:
enabled: true
timestamp: false
record:
enabled: true
Kamera_Tuerklingel:
motion:
mask:
- 203,274,640,285,640,0,0,0,0,216,0,302
improve_contrast: true
ffmpeg:
input_args:
- -avoid_negative_ts
- make_zero
- -fflags
- +genpts+discardcorrupt
- -flags
- low_delay
- -strict
- experimental
- -analyzeduration
- 1000M
- -probesize
- 1000M
- -rw_timeout
- "5000000"
inputs:
- path: http://192.168.31.242/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=
roles:
- record
- rtmp
- path: http://192.168.31.242/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=
roles:
- detect
detect:
width: 640
height: 480
fps: 12
snapshots:
enabled: True
required_zones:
- Home
record:
enabled: True
retain:
days: 5
events:
retain:
default: 10
required_zones:
- Home
objects:
track:
- person
- car
snapshots:
enabled: true
timestamp: false
record:
enabled: true
zones:
Home:
coordinates: 640,480,640,292,454,265,302,284,180,278,0,303,0,480
objects:
- person
- car
filters:
person:
min_area: 5000
max_area: 100000
threshold: 0.6
Kamera_Schuppen:
motion:
mask:
- 0,0,263,0,485,0,496,72,394,123,0,576
- 1340,245,972,47,960,0,1536,0,1536,576
improve_contrast: true
ffmpeg:
input_args:
- -avoid_negative_ts
- make_zero
- -fflags
- +genpts+discardcorrupt
- -flags
- low_delay
- -strict
- experimental
- -analyzeduration
- 1000M
- -probesize
- 1000M
- -rw_timeout
- "5000000"
inputs:
- path: http://192.168.31.161/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=admin&password=
roles:
- record
- rtmp
- path: http://192.168.31.161/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=admin&password=
roles:
- detect
detect:
width: 1536
height: 576
fps: 10
snapshots:
enabled: True
required_zones:
- Schuppen_Grundstueck
record:
enabled: True
retain:
days: 5
events:
retain:
default: 10
required_zones:
- Schuppen_Grundstueck
objects:
track:
- person
- car
snapshots:
enabled: true
timestamp: false
record:
enabled: true
zones:
Schuppen_Grundstueck:
coordinates: 0,576,388,102,485,82,479,38,864,0,1005,61,1405,279,1536,576
objects:
- person
- car
filters:
person:
min_area: 5000
max_area: 100000
threshold: 0.6
Relevant log output
[2022-12-11 13:36:20] ffmpeg.Kamera_Schuppen.detect ERROR : http://192.168.31.161/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=admin&password=: Connection refused
[2022-12-11 13:36:20] ffmpeg.Kamera_Schuppen.record_rtmp ERROR : [tcp @ 0x55ad785630] Connection to tcp://192.168.31.161:80 failed: Connection refused
[2022-12-11 13:36:20] ffmpeg.Kamera_Schuppen.record_rtmp ERROR : http://192.168.31.161/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=admin&password=: Connection refused
[2022-12-11 13:36:20] watchdog.Kamera_Schuppen INFO : Terminating the existing ffmpeg process...
[2022-12-11 13:36:20] watchdog.Kamera_Schuppen INFO : Waiting for ffmpeg to exit gracefully...
[2022-12-11 13:36:40] ws4py INFO : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:41378]
[2022-12-11 13:37:07] ws4py INFO : Terminating websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:41378]
Frigate stats
No response
Operating system
HassOS
Install method
HassOS Addon
Coral version
USB
Any other information that may be helpful
No response
What device are you running on? Doesn't look like you have hardware acceleration enabled which would be highly recommended
I have a Raspberry PI 4. Where can I enable hardware acceleration?
There's currently an issue with the pi4 hwaccel on the newer kernel , but see https://docs.frigate.video/configuration/hardware_acceleration/#raspberry-pi-34 for instructions to enable it
[2022-12-11 14:56:26] frigate.object_processing INFO : Exiting object processor... [2022-12-11 14:56:27] watchdog.Kamera_HWR ERROR : Ffmpeg process crashed unexpectedly for Kamera_HWR. [2022-12-11 14:56:27] watchdog.Kamera_HWR ERROR : The following ffmpeg logs include the last 100 lines prior to exit. [2022-12-11 14:56:27] ffmpeg.Kamera_HWR.detect ERROR : [h264_v4l2m2m @ 0x5589ceb7d0] output VIDIOC_REQBUFS failed: Invalid argument [2022-12-11 14:56:27] ffmpeg.Kamera_HWR.detect ERROR : [h264_v4l2m2m @ 0x5589ceb7d0] no v4l2 output context's buffers [2022-12-11 14:56:27] ffmpeg.Kamera_HWR.detect ERROR : [h264_v4l2m2m @ 0x5589ceb7d0] can't configure decoder [2022-12-11 14:56:27] ffmpeg.Kamera_HWR.detect ERROR : Error while opening decoder for input stream #0:0 : Inappropriate ioctl for device [2022-12-11 14:56:27] frigate.events INFO : Exiting event processor... [2022-12-11 14:56:27] peewee.sqliteq INFO : writer received shutdown request, exiting. [2022-12-11 14:56:27] root INFO : Waiting for detection process to exit gracefully...
This is in the Logs if i do this. Then nothing work.
Very weird, what version of HA OS are you running?
Home Assistant 2022.11.5 Supervisor 2022.11.2 Operating System 9.2 Frontend 20221108.0 - latest
Ensure you increase the allocated RAM for your GPU to at least 128 (raspi-config > Performance Options > GPU Memory).
Where can I do this in Homeassistant? I did not have Raspian.
Odds are this is an issue with the kernel, see https://github.com/blakeblackshear/frigate/issues/3780
Ok but what is the solution? I only installed Homeassistant and no Raspbian. Where can I downgrade the Kernel?
I wouldn't recommend that, most likely need to just wait for ffmpeg to issue a fix. hwaccel should speed up the decoding of the stream which will reduce delay.
also, is 720x480 the native resolution of your stream?
No I have set the native resolution in the config vor every Camere each like this:
detect: width: 1536 height: 576
One of them is set with
detect:
width: 720
height: 480
So just making sure 👍
Yes I have different Cameras with different native resolution.
So I must wait if comes an Update?
For hwaccel, yes, it needs to be fixed my ffmpeg
If you're happy to do this, drop the HAOS version back to 8.5 and this will restore hardware decoding:
ha os update --version 8.5
As it happens, I've just done this myself as I suspect the real fix might take quite a while to propagate into ffmpeg. No problems at all - one command, and it took around 10 mins to install and reboot, with no obvious negative side effects. Note: this does not affect the version of HA you are running, just the underlying host OS.
[2022-12-14 21:49:46] ffmpeg.Kamera_Tuerklingel.detect ERROR : [h264_v4l2m2m @ 0x55ab9b0a50] no v4l2 output context's buffers [2022-12-14 21:49:46] ffmpeg.Kamera_Tuerklingel.detect ERROR : [h264_v4l2m2m @ 0x55ab9b0a50] can't configure decoder [2022-12-14 21:49:46] ffmpeg.Kamera_Tuerklingel.detect ERROR : Error while opening decoder for input stream #0:0 : Inappropriate ioctl for device [2022-12-14 21:49:46] watchdog.Kamera_Schuppen ERROR : Ffmpeg process crashed unexpectedly for Kamera_Schuppen. [2022-12-14 21:49:46] watchdog.Kamera_Schuppen ERROR : The following ffmpeg logs include the last 100 lines prior to exit.
That is my log. I do ha os update befor.
I have transfer my Installation to a Intel NUC 10 i5 with the same frigate.yml. The delay is always there.
What hardware acceleration method are you using?
I have used:
ffmpeg: hwaccel_args: -c:v h264_qsv
but the nothing work all are green
Include logs otherwise won't be able to help.
[2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Failed to create a VAAPI device. [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Error initializing an MFX session [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Error decoding header [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Error while decoding stream #0:0: Generic error in an external library [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Error querying IO surface: unsupported (-3) [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Error while decoding stream #0:0: Function not implemented [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Error querying IO surface: unsupported (-3) [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Error while decoding stream #0:0: Function not implemented [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Error querying IO surface: unsupported (-3) [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Error while decoding stream #0:0: Function not implemented [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] Error querying IO surface: unsupported (-3) [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Error while decoding stream #0:0: Function not implemented [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] video_get_buffer: image parameters invalid [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : [h264_qsv @ 0x55e485aebe00] get_buffer() failed [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Error while decoding stream #0:0: Invalid argument [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Finishing stream 0:0 without any data written to it. [2022-12-23 22:45:54] ffmpeg.Kamera_Schuppen.detect ERROR : Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Maybe try VAAPI, what generation i5 is it?
Yes VAAPI but who install it? im not very good on Linux.
Just set different args in the config https://docs.frigate.video/configuration/hardware_acceleration#intel-based-cpus-10th-generation-via-quicksync
I didnot understand it. Can you explain it a little bit?
The args are shown there in the docs I linked, replace the -c:v h264_qsv
with the args in the linked sections with -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
ffmpeg: hwaccel_args: LIBVA_DRIVER_NAME=i965
or
ffmpeg: hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
That also did not work.
If it didn't work include logs, i965 is a separate unrelated thing
[2022-12-23 23:19:47] ffmpeg.Kamera_Tuerklingel.detect ERROR : [NULL @ 0x55914fa18d80] Unable to find a suitable output format for 'LIBVA_DRIVER_NAME=i965' [2022-12-23 23:19:47] ffmpeg.Kamera_Tuerklingel.detect ERROR : LIBVA_DRIVER_NAME=i965: Invalid argument [2022-12-23 23:19:47] watchdog.Kamera_Schuppen INFO : Waiting for ffmpeg to exit gracefully... [2022-12-23 23:19:47] ffmpeg.Kamera_Tuerklingel.record_rtmp ERROR : [NULL @ 0x55b5a5904ac0] Unable to find a suitable output format for 'LIBVA_DRIVER_NAME=i965' [2022-12-23 23:19:47] ffmpeg.Kamera_Tuerklingel.record_rtmp ERROR : LIBVA_DRIVER_NAME=i965: Invalid argument [2022-12-23 23:19:47] watchdog.Kamera_Tuerklingel INFO : Terminating the existing ffmpeg process... [2022-12-23 23:19:47] watchdog.Kamera_Tuerklingel INFO : Waiting for ffmpeg to exit gracefully...
ffmpeg: hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
Is what should be used
[2022-12-23 23:23:39] ffmpeg.Kamera_Tuerklingel.detect ERROR : [AVHWDeviceContext @ 0x55717a71fe00] No VA display found for device /dev/dri/renderD128. [2022-12-23 23:23:39] ffmpeg.Kamera_Tuerklingel.detect ERROR : Device creation failed: -22. [2022-12-23 23:23:39] ffmpeg.Kamera_Tuerklingel.detect ERROR : [h264 @ 0x55717a642900] No device available for decoder: device type vaapi needed for codec h264. [2022-12-23 23:23:39] ffmpeg.Kamera_Tuerklingel.detect ERROR : Device setup failed for decoder on input stream #0:0 : Invalid argument [2022-12-23 23:23:39] ws4py INFO : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:39470] [2022-12-23 23:23:41] frigate.video ERROR : Kamera_HWR: Unable to read frames from ffmpeg process. [2022-12-23 23:23:41] frigate.video ERROR : Kamera_HWR: ffmpeg process is not running. exiting capture thread... [2022-12-23 23:23:41] frigate.video ERROR : Kamera_Schuppen: Unable to read frames from ffmpeg process. [2022-12-23 23:23:41] frigate.video ERROR : Kamera_Schuppen: ffmpeg process is not running. exiting capture thread... [2022-12-23 23:23:42] ws4py INFO : Terminating websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:39470] [2022-12-23 23:23:43] frigate.video ERROR : Kamera_Tuerklingel: Unable to read frames from ffmpeg process. [2022-12-23 23:23:43] frigate.video ERROR : Kamera_Tuerklingel: ffmpeg process is not running. exiting capture thread...