Commit Graph

887 Commits

Author SHA1 Message Date
Nicolas Mowen
baf671b764
Cleanup and organize utils (#7033)
* Force birdseye cameras into standard aspect ratios

* Organize utils

* Update tests

* Formatting

* Isort

* Fix tests

* Cleanup

* isort
2023-07-06 09:28:50 -05:00
Cody Cutrer
2fae9dcb93
reduce contention on frame_queue (#6890)
* reduce contention on frame_queue

don't check if the queue is full, just attempt to add the frame
in a non-blocking manner, and then if it fails, skip it

* don't check if the frame queue is empty, just try and get from it

* Update frigate/video.py

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-07-06 08:18:39 -05:00
Sergey Krashevich
c38c981cd0
Performance: multiprocessing improvement: step 2 (#6986)
* Refactored queues to use faster_fifo instead of mp.Queue

* Refactored LimitedQueue to include a counter for the number of items in the queue and updated put and get methods to use the counter

* Refactor app.py and util.py to use a custom Queue implementation called LQueue instead of the existing Queue

* Refactor put and get methods in LimitedQueue to handle queue size and blocking behavior more efficiently

* code format

* remove code from other branch (merging fuckup)
2023-07-06 07:56:38 -05:00
Nicolas Mowen
d0891e5183
Ptz cleanup (#6999)
* Use _ instead of - for ptz presets

* Update mqtt.md

* Fix

* Formatting
2023-07-06 07:42:17 -05:00
Andrew Reiter
325205740b
Check ffmpeg version instead of checking for presence of BTBN_PATH (#7023)
* Check ffmpeg version instead of checking for presence of BTBN_PATH

* Query ffmpeg version in s6 run script instead of subprocessing in every import

* Define LIBAVFORMAT_VERSION_MAJOR in devcontainer too

* Formatting

* Default ffmpeg version to current btbn version so unit tests pass
2023-07-06 07:35:26 -05:00
Andrew Reiter
f30ba25444
Reduce framerate before downscaling (#7022)
* Reduce framerate before downscaling

It is cheaper to drop frames and downscale those that remain than it is
to downscale all frames and then drop some of them. This is achieved
with the filter chain `-cv fps=FPS,scale=W:H`, and perhaps was the
original intention. The plain `-r` and `-s` flags do not execute in
order though - they each put themselves at the *end* of the filterchain,
so `-r FPS -s WxH` actually applies the scale filter first, and then the
rate filter.

This fix can halve the CPU used by the detect ffmpeg process.

* Bring back hard rate limits
2023-07-06 07:31:17 -05:00
Nicolas Mowen
339b6944f1
Force birdseye cameras into standard aspect ratios (#7026)
* Force birdseye cameras into standard aspect ratios

* Clarify comment

* Formatting

* Actually use the calculated aspect ratio when building the layout

* Fix Y aspect

* Force canvas into known aspect ratio as well

* Save canvas size and don't recalculate

* Cache coefficients that are used for different size layouts

* Further optimize calculations to not be done multiple times
2023-07-06 07:30:05 -05:00
Nicolas Mowen
0f68fbc8db
Use pre capture for custom events (#7038)
* Use pre capture for custom events

* Formatting
2023-07-06 07:26:53 -05:00
Nicolas Mowen
998bffe706
Fix min region size not being divisible by 4 (#7040)
* Fix min region size not being divisible by 4

* Simplify half calculation
2023-07-06 07:25:37 -05:00
Sergey Krashevich
12d4a47e3d
End audio event and update detections if successful, otherwise log a warning if ending audio event fails with a specific status code (#6984) 2023-07-03 09:50:25 -05:00
Sergey Krashevich
f905704479
UI: add audio process stats to System page (#6993)
* Add audio process PID to the list of processes and log the start of the audio process

* Update audio process PID key in processes dictionary to "audioDetector" instead of "audio".
2023-07-03 09:48:29 -05:00
Nicolas Mowen
58c6ef1e12
Add designator when events are from the api (#6997)
* Add designator when events are custom

* Add type field and set via API
2023-07-03 09:48:00 -05:00
Nicolas Mowen
83edf9574e
Scale birdseye layout up to max size after it has been calculated (#6825)
* Scale layout up to max size after it has been calculated

* Limit portrait cameras to taking up 2 rows

* Fix bug

* Fix birdsye not removing cameras once objects are no longer visible

* Fix lint
2023-07-02 07:45:45 -05:00
Nicolas Mowen
c25367221e
Fix audio events not being ended (#6981)
* Fix audio events not being ended

* Fix audio events not being ended correctly

* Clean up debug code
2023-07-01 16:33:47 -05:00
Nicolas Mowen
7ee17c7af8
Fix small audio events details (#6978)
* Fix missed audio details

* Add mqtt docs

* Delete instead of setting to None
2023-07-01 11:19:14 -05:00
Nicolas Mowen
c3b313a70d
Audio events (#6848)
* Initial audio classification model implementation

* fix mypy

* Keep audio labelmap local

* Cleanup

* Start adding config for audio

* Add the detector

* Add audio detection process keypoints

* Build out base config

* Load labelmap correctly

* Fix config bugs

* Start audio process

* Fix startup issues

* Try to cleanup restarting

* Add ffmpeg input args

* Get audio detection working

* Save event to db

* End events if not heard for 30 seconds

* Use not heard config

* Stop ffmpeg when shutting down

* Fixes

* End events correctly

* Use api instead of event queue to save audio events

* Get events working

* Close threads when stop event is sent

* remove unused

* Only start audio process if at least one camera is enabled

* Add const for float

* Cleanup labelmap

* Add audio icon in frontend

* Add ability to toggle audio with mqtt

* Set initial audio value

* Fix audio enabling

* Close logpipe

* Isort

* Formatting

* Fix web tests

* Fix web tests

* Handle cases where args are a string

* Remove log

* Cleanup process close

* Use correct field

* Simplify if statement

* Use var for localhost

* Add audio detectors docs

* Add restream docs to mention audio detection

* Add full config docs

* Fix links to other docs

---------

Co-authored-by: Jason Hunter <hunterjm@gmail.com>
2023-07-01 08:18:33 -05:00
Blake Blackshear
2f401bd8da
update deps (#6973)
* update web deps

* update python deps
2023-07-01 07:47:16 -05:00
Nicolas Mowen
f3f9b36e07
Fix bad check on np.array (#6968) 2023-06-30 07:06:38 -06:00
Nicolas Mowen
0a8249d6fb
Fix Bad Resize For Camera Snapshot (#6797)
* Catch cases where incorrect size is requested

* Set a default if calculated height is incorrect
2023-06-30 07:34:10 -05:00
Blake Blackshear
d51197eaa2
use a different method for blur and contrast to reduce CPU (#6940)
* use a different method for blur and contrast to reduce CPU

* blur with radius instead

* use faster interpolation for motion

* improve contrast based on averages

* increase default threshold to 30

* ensure mask is applied after contrast improvement

* update opencv

* update benchmark script
2023-06-30 07:27:31 -05:00
Nicolas Mowen
d2a2643cd6
Apply zone filter before inertia (#6854)
* Apply zone filter before intertia

* Formatting
2023-06-30 07:15:55 -05:00
spacebares
ed0d2be321
configurable ffmpeg timeout (#6897)
* configurable ffmpeg timeout

* configurable ffmpeg healthcheck interval

rename timeout to healthcheck_interval
only grab config value once

* configurable ffmpeg retry interval

rename healthcheck_interval to retry_interval

* add retry_interval to docs

- update retry_interval text in config.py
2023-06-30 07:14:39 -05:00
Nicolas Mowen
9137f1594b
Remove legacy recordings file cleanup (#6947)
* Remove legacy recordings file cleanup

* Remove unused
2023-06-30 07:13:00 -05:00
Cody Cutrer
ef14a43930
optimize frame-per-second calculations (#6887)
* optimize frame-per-second calculations

FPS is never calculated over differing periods for even given
counter. By only storing timestamps within the period that is
used, we avoid having to iterate 1000 entries every time it's
re-calculated (multiple times per second). 1000 entries would
normally only be needed if something is running at 100fps. A
more common speed - anywhere from 5 to 30fps, only needs 50
to 300 entries.

This isn't a huge improvement in the grand scheme, but when motion
detection is disabled, it takes nearly as much time in a flamegraph
as actually transferring the video frame.

* fix python checks
2023-06-28 05:55:53 -05:00
Cody Cutrer
ee4a133655
actually keep track of skipped frames (#6889)
* actually keep track of skipped frames

fixes #6863

* fix black errors
2023-06-28 05:53:28 -05:00
Nicolas Mowen
ece070fee1
Load labels dynamically for event filters (#6896)
* Load labels dynamically to include custom events and audio, do not include attribute labels

* Formatting

* Fix sorting

* Also filter tracked object list on camera page

* isort

* Don't fail before load
2023-06-28 05:51:53 -05:00
Sergey Krashevich
e640981cc4
Performance: multiprocessing improvement (#6936)
* Add faster-fifo dependency for improved performance

* isort
2023-06-28 05:39:39 -05:00
Blake Blackshear
9e531b0b5b
reduce grid size for contrast improvement (#6870) 2023-06-21 08:38:51 -05:00
Blake Blackshear
7c1568fcb9
use clahe for contrast improvement (#6835)
* use clahe for contrast improvement

* update tests
2023-06-18 11:56:41 -05:00
Nicolas Mowen
09cc4251f0
Fix dict getting overwritten (#6830) 2023-06-17 10:31:35 -05:00
Blake Blackshear
793fe251b9
Label attributes (#6829)
* pass attribute labels as attributes

* add label attrs to events and snapshots

* incorporate area of license_plate and face into snapshot selection

* populate sublabels for cars with logos
2023-06-17 09:56:22 -05:00
Nicolas Mowen
2be2050d57
Don't fail to save segment when cv2 fails (#6823)
* Don't fail when cv2 fails

* Clean up exception handling
2023-06-17 09:56:00 -05:00
Nicolas Mowen
b66810247e
Optimize stacked recordings (#6809)
* Make camera recordings mover asynchronous

* Formatting

* Move to using cv2 instead of external ffmpeg process

* Use ffprobe if cv2 failed

* Formatting

* Fix bad access

* Formatting

* Update frigate/record/maintainer.py

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

* Update name of caller

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-06-16 07:09:13 -06:00
Nicolas Mowen
0592cedcde
Rewrite birdseye auto layout (#6818)
* Prefer horizontal layout to vertical

* Rewrite birdseye to use aspect ratios instead of resolutions as layout configurator

* Improve layout with slightly larger than 16:9 cameras

* Remove manual 2 camera layout

* Lint

* Remove log
2023-06-16 07:35:36 -05:00
Blake Blackshear
ca7853c087
Fix max_frames, improve stationary objects in masked areas (#6815)
* fix issue with max_frames

* dont consider stationary until the threshold

* require a stationary interval

* try to fix formatter issues
2023-06-16 07:32:43 -05:00
Sergey Krashevich
3efa77f302
Round the timestamp value read from .vacuum file to prevent potential errors caused by float values (#6800) 2023-06-14 17:19:26 -05:00
Nicolas Mowen
7e5abe7a65
Optimize Birdseye layout for portrait cameras (#6779)
* Handle vertical cameras more optimally in 2 camera layout

* Optimize portrait layout for 3+ cams

* Remove logging
2023-06-12 17:39:12 -05:00
Nicolas Mowen
ec4d79eafc
Fix bug in intersection logic (#6780)
* Fix bug in intersection logic

* Fix isort

* Remove unrelated test

* Formatting

* Fix type in test
2023-06-12 17:38:22 -05:00
Nicolas Mowen
ff90db30e6
Various Bug Fixes (#6768)
* Fix birdseye infinite loop

* Fix division by zero
2023-06-12 06:06:02 -04:00
Sergey Krashevich
dfd574beeb
Refactor storage stats calculation to use powers of 2 for more accurate values (#6765)
* "Refactor storage stats calculation to use powers of 2 for more accurate values"

* replace 1000000 to 2^20

* Refactor storage unit size display to use binary prefixes

This commit updates the display of storage unit sizes in both the camera storage stats and the Storage component in the web UI to use binary prefixes (MiB and GiB) instead of decimal prefixes (MB and GB). This provides more accurate and consistent representation of storage sizes
2023-06-11 14:49:13 -05:00
Nicolas Mowen
0f1cf67b91
Fix birdseye optimistic approach (#6764) 2023-06-11 08:47:34 -05:00
Blake Blackshear
d81dd60fef
Improve motion detection and region selection (#6741)
* refactor existing motion detector

* implement and use cnt bgsub

* pass fps to motion detector

* create a simplified motion detector

* lightning detection

* update default motion config

* lint imports

* use estimated boxes for regions

* use improved motion detector

* update test

* use a different strategy for clustering motion and object boxes

* increase alpha during calibration

* simplify object consolidation

* add some reasonable constraints to the estimated box

* adjust cluster boundary to 10%

* refactor

* add disabled debug code

* fix variable scope
2023-06-11 08:45:11 -05:00
Nicolas Mowen
32569842d3
Option to enable / disable stats that require external processes (#6615)
* Add option for network bandwidth and only calculate if enabled

* Don't show network bandwidth in system stats page if not enabled

* Formatting

* Hide other rows as well

* Add docs

* Add config options for AMD and Intel GPU stats

* Fix stats access

* Update docs

* Use correct bool syntax

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-06-11 08:26:34 -05:00
Sergey Krashevich
5c27cb7e9b
Optimization of Sync Records: Implementing Pagination and Temporary Table (#6585)
* Update pull_request.yml

* Add temporary table for deletion and use pagination to process recordings in chunks for deletion of recordings with missing files

* move RecordingsToDelete class to models.py

* recording cleanup: bugfixes

* Update cleanup.py

* improve log message in cleanup.py

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-06-11 08:01:50 -05:00
Nicolas Mowen
b160abac0d
Ability to configure min frames for zone presence (#6680)
* Objects need to be in zones multiple times to be considered present in the zone

* Add a field to configure inertia per zone

* Formatting

* Use correct default method

* Clarify zone presence behavior

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-06-11 08:00:53 -05:00
Nicolas Mowen
fd6eb78f41
Birdseye Autolayout (#6734)
* Calculate possible layout

* Working in ideal conditions

* Fix issues with different heights

* Remove logs

* Optimally handle cameras that don't match the canvas aspect ratio

* Make sure to copy so list is not overwritten

* Remove unused import

* Remove try catch

* Optimize layout for low amount of cameras

* Try to scale frames up if not enough space is used
2023-06-11 07:54:18 -05:00
Sergey Krashevich
8d941e5e26
Add function to get physical interfaces for bandwidth calculation (#6618)
* Add function to get physical interfaces for bandwidth calculation in get_bandwidth_stats() function

* Add telemetry configuration option for enabled network interfaces, with default values for monitoring bandwidth stats for camera ffmpeg processes, go2rtc, and object detectors. Also add support for FrigateConfig in set_bandwidth_stats function to get bandwidth stats for specified network interfaces
2023-06-11 07:34:03 -05:00
Nicolas Mowen
8bc76d19db
DB Optimizations (#6712)
* Enable auto vacuums

* Enable auto vacuum

* Fix separator

* Fix separator and remove incorrect log

* Limit to 1 row since that is all that is used

* Add index on camera + segment_size

* Formatting

* Increase timeout and cache_size

* Set DB mode to NORMAL synchronous level

* Formatting

* Vacuum every 2 weeks

* Remove fstring

* Use string

* Use consts
2023-06-11 07:23:18 -05:00
Nicolas Mowen
435d152423
Fix bug introduced in new linter (#6754)
* Fix bug introduced in new linter

* Ignore this error

* Fix more

* Ignore boolean error too
2023-06-11 07:18:47 -05:00
Nicolas Mowen
d3949eebfa
Add API and WebUI to export recordings (#6550)
* Add ability to export frigate clips

* Add http endpoint

* Add dir to nginx

* Add webUI

* Formatting

* Cleanup unused

* Optimize timelapse

* Fix pts

* Use JSON body for params

* Use hwaccel to encode when available

* Print ffmpeg command when fail

* Print ffmpeg command when fail

* Add separate ffmpeg preset for timelapse

* Add docs outlining the export directory

* Add export docs

* Use ''

* Fix playlist max time

* Lower max playlist time

* Add api docs for export

* isort fixes
2023-06-08 07:32:35 -04:00