Commit Graph

127 Commits

Author SHA1 Message Date
Nicolas Mowen
6c0978498d
Abstract MQTT from communication and make mqtt optional (#4462)
* Add option for mqtt config

* Setup communication layer

* Have a dispatcher which is responsible for handling and sending messages

* Move mqtt to communication

* Separate ws communications module

* Make ws client conform to communicator

* Cleanup imports

* Migrate to new dispatcher

* Clean up

* Need to set topic prefix

* Remove references to mqtt in dispatcher

* Don't start mqtt until dispatcher is subscribed

* Cleanup

* Shorten package

* Formatting

* Remove unused

* Cleanup

* Rename mqtt to ws on web

* Fix ws mypy

* Fix mypy

* Reformat

* Cleanup if/else chain

* Catch bad set commands
2022-11-23 20:03:20 -06:00
Nicolas Mowen
ebdf36e0b9
Refactor mqtt to handle reconnects and not cause frigate to stop. (#4440)
* Refactor mqtt client

* Protect callback method

* Use async to handle reconnects

* Set types and clenup

* Don't set connected until rc code is checked
2022-11-20 07:36:01 -06:00
herostrat
2e81c94d8e
Typing Part 3: events.py (#3352)
* Typing: events.py

* Remove unused variable

* Fix return Any from return statement

Not all elements from the event dict are sure to be something that can be evaluated

See e.g.: https://github.com/python/mypy/issues/5697

* Sort out Event disambiguity

There was a name collision of multiprocessing Event type and frigate events

Co-authored-by: Sebastian Englbrecht <sebastian.englbrecht@kabelmail.de>
2022-11-19 07:16:33 -06:00
Nicolas Mowen
a04fa105ef
Fix internal restream error and add docs for reducing camera connections (#4431)
* Start restream before detection

* Add docs explaining how to reduce connections to the camera

* Fix typos for consistency

* Add link to other part of doc for readability
2022-11-19 07:15:20 -06:00
Nate Meyer
4383b883c0
Refactor to simplify support for additional detector types (#3656)
* Refactor EdgeTPU and CPU model handling to detector submodules.

* Fix selecting the correct detection device type from the config

* Remove detector type check when creating ObjectDetectProcess

* Fixes after rebasing to 0.11

* Add init file to detector folder

* Rename to detect_api

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

* Add unit test for LocalObjectDetector class

* Add configuration for model inputs
Support transforming detection regions to RGB or BGR.
Support specifying the input tensor shape.  The tensor shape has a standard format ["BHWC"] when handed to the detector, but can be transformed in the detector to match the model shape using the model  input_tensor config.

* Add documentation for new model config parameters

* Add input tensor transpose to LocalObjectDetector

* Change the model input tensor config to use an enumeration

* Updates for model config documentation

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2022-11-03 21:23:09 -05:00
banthungprong
8163afce79
Allow cameras to be disabled in config (#4162)
* add option enabled for each camera in config

* Simplified If-block and removed wrong Optional

* Update Docs enabling/disabling camera in config

* correct format for option

* Disabling Camera for processes, no config changes

* Describe effects of disabled cam in documentation

* change if-logic, obsolete copy, info disabled cam

* changed color to white, added top padding in disabled camera info

* changed indentation
2022-11-02 06:41:44 -05:00
Nicolas Mowen
d8123d2497
Add go2rtc and add restream role / live source (#4082)
* Pull go2rtc dependency

* Add go2rtc to local services and add to s6

* Add relay controller for go2rtc

* Add restream role

* Add restream role

* Add restream to nginx

* Add camera live source config

* Disable RTMP by default and use restream

* Use go2rtc for camera config

* Fix go2rtc move

* Start restream on frigate start

* Send restream to camera level

* Fix restream

* Make sure jsmpeg works as expected

* Make view rspect live size config

* Tweak player options to fit live view

* Adjust VideoPlayer to accept live option which disables irrelevant controls

* Add multiple options from restream live view

* Add base for webrtc option

* Setup specific restream modules

* Make mp4 the default streaming for now

* Expose 8554 for rtsp relay from go2rtc

* Formatting

* Update docs to suggest new restream method.

* Update docs to reflect restream role

* Update docs to reflect restream role

* Add webrtc player

* Improvements to webRTC

* Support webrtc

* Cleanup

* Adjust rtmp test and add restream test

* Fix tests

* Add restream tests

* Add live view docs and show different options

* Small docs tweak

* Support all stream types

* Update to beta 9 of go2rtc

* Formatting

* Make jsmpeg the default

* Support wss if made from https

* Support wss if made from https

* Use onEffect

* Set url outside onEffect

* Fix passed deps

* Update docs about required host mode

* Try memo instead

* Close websocket on changing camera

* Formatting

* Close pc connection

* Set video source to null on cleanup

* Use full path since go2rtc can't see PATH var

* Adjust audio codec to enable browser audio by default

* Cleanup stream creation

* Add restream tests

* Format tests

* Mock requests

* Adjust paths

* Move stream configs to restream

* Remove live source

* Remove live config

* Use live persistence for which view to use on each camera

* Fix live sizes

* Only use jsmpeg sizes for jsmpeg live

* Set max live size

* Remove access of live config

* Add selector for live view source in web view

* Remove RTMP from default list of roles

* Update docs

* Fix tests

* Fix docs for live view modes

* make default undefined to avoid race condition

* Wait until camera source is loaded to avoid race condition

* Fix tests

* Add config to go2rtc

* Work with config

* Set full path for config

* Set to use stun

* Check for mounted file

* Look for frigate-go2rtc

* Update docs to reflect webRTC configuration.

* Add link to go2rtc config

* Update docs to be more clear

* Update docs to be more clear

* Update format

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>

* Update live docs

* Improve bash startup script

* Add option to force audio compatibility

* Formatting

* Fix mapping

* Fix broken link

* Update go2rtc version

* Get go2rtc webui working

* Add support for mse

* Remove mp4 option

* Undo changes to video player

* Update docs for new live view options

* Make separate path for mse

* Remove unused

* Remove mp4 path

* Try to get go2rtc proxy working

* Try to get go2rtc proxy working

* Remove unused callback

* Allow websocket on restrea dashboard

* Make mse default stream option

* Fix mse sizing

* don't assume roles is defined

* Remove nginx mapping to go2rtc ui

Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2022-11-02 06:36:09 -05:00
Nicolas Mowen
b4d4adb75b
Limit recording retention to available storage (#3942)
* Add field and migration for segment size

* Store the segment size in db

* Add comment

* Add default

* Fix size parsing

* Include segment size in recordings endpoint

* Start adding storage maintainer

* Add storage maintainer and calculate average sizes

* Update comment

* Store segment and hour avg sizes per camera

* Formatting

* Keep track of total segment and hour averages

* Remove unused files

* Cleanup 2 hours of recordings at a time

* Formatting

* Fix bug

* Round segment size

* Cleanup some comments

* Handle case where segments are not deleted on initial run or is only retained segments

* Improve cleanup log

* Formatting

* Fix typo and improve logging

* Catch case where no recordings exist for camera

* Specifically define sort

* Handle edge case for cameras that only record part time

* Increase definition of part time recorder

* Remove warning about not supported storage based retention

* Add note about storage based retention to recording docs

* Add tests for storage maintenance calculation and cleanup

* Format tests

* Don't run for a camera with no recording segments

* Get size of file from cache

* Rework camera stats to be more efficient

* Remove total and other inefficencies

* Rewrite storage cleanup logic to be much more efficient

* Fix existing tests

* Fix bugs from tests

* Add another test

* Improve logging

* Formatting

* Set back correct loop time

* Update name

* Update comment

* Only include segments that have a nonzero size

* Catch case where camera has 0 nonzero segment durations

* Add test to cover zero bandwidth migration case

* Fix test

* Incorrect boolean logic

* Formatting

* Explicity re-define iterator
2022-10-09 06:28:26 -05:00
Josh Hawkins
7845995dfd Adjust threshold and contour_area with mqtt 2022-07-05 08:46:10 -05:00
Nicolas Mowen
0a4d658c7f
Ability to enable / disable motion detection via MQTT (#3117)
* Starting working on adding motion toggle

* Add all info to mqtt command

* Send motion to correct funs

* Update mqtt docs

* Fixes for contingencies

* format

* mypy

* Tweak behavior

* Fix motion breaking frames

* Fix bad logic in detect set

* Always set value for motion boxes
2022-04-26 07:29:28 -05:00
Sebastian Englbrecht
cafe0917c7 Typing: mypy fixes for
* __main__.py
 * app.py
 * models.py
 * plus.py
 * stats.py

In addition a new module was introduced: types
There all TypedDicts are included. Bitte geben Sie eine Commit-Beschreibung für Ihre Änderungen ein. Zeilen,
2022-04-17 08:55:38 -05:00
Blake Blackshear
ec91466fe4 lint fixes 2022-04-16 09:08:10 -05:00
Josh Hawkins
65e0ec7826
Allow improve_contrast to be toggled via mqtt (#3011)
* Toggle improve_contrast for cameras via MQTT

* Process parameter to mqtt toggle improve_contrast

* Update mqtt docs for improve_contrast topic

* Spacing

* Add class variable and update in process_frames

* Pass to constructor

* pass by reference mistake

* remove parameter

* remove parameter
2022-04-16 08:52:02 -05:00
Blake Blackshear
e724fe3da6 add endpoint to submit to plus 2022-04-10 09:11:16 -05:00
Blake Blackshear
7401cf2399 add stacktrace to config validation errors 2022-02-18 21:18:26 -06:00
Yuriy Sannikov
6eecb6780e Run python unit tests in a github actions (#2589)
* tox tests initial commit

* run tests in the Dockerfile during the build phase

* remove local tests

Co-authored-by: YS <ys@gm.com>
2022-02-18 21:18:26 -06:00
Justin Goette
f91f4f0053 Allow for ".yaml" (#2244)
* allow for ".yaml"

* remove unused import
2022-02-18 21:18:26 -06:00
Blake Blackshear
ef214fb80a retain frame data for recording maintenance 2022-02-18 21:18:26 -06:00
Blake Blackshear
b29b311e92 fix ffmpeg config for env vars 2022-02-18 21:18:26 -06:00
Blake Blackshear
86a741b6e6 assign roles when single input and consolidate validation 2021-10-16 07:46:39 -05:00
Blake Blackshear
f738275d21 yell about config validation errors
for the people in the back
2021-10-16 07:17:36 -05:00
Blake Blackshear
f83d4a58dd add version to the logs on startup 2021-09-13 22:02:23 -05:00
Jason Hunter
a7b7a45b23 allow for custom object detection model via configuration 2021-09-12 07:17:26 -05:00
Blake Blackshear
45798d6d14 clean house on clips 2021-08-15 08:30:27 -05:00
Jason Hunter
181a504a14 break out recording maintenance and cleanup into separate threads 2021-08-07 15:51:16 -05:00
Blake Blackshear
92aa16c556 add labelmap customization to the config (fixes #507) 2021-07-07 22:58:18 -05:00
Jason Hunter
c664bd63f6 initial conversion to pydantic 2021-06-24 06:53:05 -05:00
mrdrup
f110a261b9
Fix 'FileExistsError' shared memory exception (#945) 2021-06-19 07:15:02 -05:00
Blake Blackshear
40bf7a0f41 cleanup 2021-06-14 07:48:35 -05:00
Blake Blackshear
cbdf2c2c71 remove gevent fixes #920 2021-06-14 07:48:35 -05:00
Blake Blackshear
ed761d1767 cap the array size of the output queue 2021-06-12 07:23:14 -05:00
Blake Blackshear
8e2ba4a8ea move birdseye placeholder to output process 2021-06-12 07:23:14 -05:00
Blake Blackshear
8413e10091 ensure output exits properly 2021-06-12 07:23:14 -05:00
Blake Blackshear
5afda72b84 handle exit signals 2021-06-12 07:23:14 -05:00
Blake Blackshear
7a6ffb1032 adding output process to handle downstream processing of frames 2021-06-12 07:23:14 -05:00
Blake Blackshear
7fc9026ca6 basic plumbing for birdseye view 2021-06-12 07:23:14 -05:00
Jason Hunter
055bd22138 initial implementation of recordings table 2021-06-10 07:04:28 -05:00
Jason Hunter
aab6a00e4c Add support for NGINX VOD Module 2021-05-22 07:48:44 -05:00
Blake Blackshear
4252857e19 remove tmpfs_cache_size option 2021-02-25 07:01:59 -06:00
Blake Blackshear
39ff49e054 formatting cleanup 2021-02-25 07:01:57 -06:00
Blake Blackshear
718b4f3fd7 relay mqtt to clients 2021-02-20 08:20:17 -06:00
Blake Blackshear
22461d1728 simple echo websocket working 2021-02-20 08:20:17 -06:00
Blake Blackshear
01c3b4fa6e try and ensure database closes cleanly 2021-02-20 08:20:17 -06:00
Blake Blackshear
630c2ee6f6 use sqlitequeuedb 2021-01-26 21:40:33 -06:00
Blake Blackshear
11016b8486 ensure error message with missing config is printed 2021-01-26 21:40:33 -06:00
Blake Blackshear
7f663328dc initialize detection correctly from config 2021-01-26 21:40:33 -06:00
Blake Blackshear
97e8258288 add env vars to config
fixes #509
2021-01-26 21:40:33 -06:00
Blake Blackshear
39040c1874 enable and disable detection via mqtt 2021-01-26 21:40:33 -06:00
Blake Blackshear
5ad4017510 try to cleanup some migration logging 2021-01-26 21:40:33 -06:00
Blake Blackshear
c770470b58 add database migrations 2021-01-26 21:40:33 -06:00
Nat Morris
76403bba8e New stats module, refactor stats generation out of http module.
StatsEmitter thread to send stats to MQTT every 60 seconds by default, optional stats_interval config value.

New service stats attribute, containing uptime in seconds and version.
2021-01-26 21:40:33 -06:00
Blake Blackshear
e5399ae07a enable turning clips on and off via mqtt 2021-01-26 21:40:33 -06:00
Blake Blackshear
80a5a7b129 cleanup save_Clips/clips inconsistency 2021-01-26 21:40:33 -06:00
Blake Blackshear
9f504253fb fix tmpfs 2021-01-26 21:40:33 -06:00
Blake Blackshear
961997e078 remove redundant error output 2021-01-26 21:40:33 -06:00
Blake Blackshear
363594a9a2 use CACHE_DIR constant 2021-01-26 21:40:33 -06:00
Blake Blackshear
247e2677f3 enable mounting tmpfs volume on start 2021-01-26 21:40:33 -06:00
Blake Blackshear
32fb76b3d1 add num_threads fixes #322 2021-01-26 21:40:33 -06:00
Blake Blackshear
dd102ff01d allow db path to be customized 2021-01-26 21:40:33 -06:00
Blake Blackshear
d0470fffcc allow defining model shape and switch to mobiledet as default model 2021-01-26 21:40:33 -06:00
Blake Blackshear
3c07767138 handle and warn if roles dont match enabled features 2021-01-26 21:40:33 -06:00
Blake Blackshear
e7cdace0ab comment you zeroconf 2021-01-26 21:40:33 -06:00
Blake Blackshear
f60eb4e977 fix flask logger config 2021-01-26 21:40:33 -06:00
Blake Blackshear
7aecf6c6de fix graceful exits 2021-01-26 21:40:33 -06:00
Blake Blackshear
75d62096a6 better exception handling 2021-01-26 21:40:33 -06:00
Blake Blackshear
d60ca9d783 log level configuration 2021-01-26 21:40:33 -06:00
Blake Blackshear
47e256f03d add logging for directory creation 2021-01-26 21:40:33 -06:00
Blake Blackshear
527db52d5e exit on config errors 2021-01-26 21:40:33 -06:00
Blake Blackshear
f78b2c48a7 add zeroconf discovery 2021-01-26 21:40:33 -06:00
Blake Blackshear
735cc3962b make directories constants 2021-01-26 21:40:33 -06:00
Blake Blackshear
feb42181de cleanup empty directories 2021-01-26 21:40:33 -06:00
Blake Blackshear
65ddd91855 add recording maintenance 2021-01-26 21:40:33 -06:00
Blake Blackshear
60207723d1 pull from memory if event in progress 2021-01-26 21:40:33 -06:00
Blake Blackshear
0dad9bc393 add event cleanup thread 2021-01-26 21:40:33 -06:00
Blake Blackshear
ec1a8ebd4a fixes 2021-01-26 21:40:33 -06:00
Blake Blackshear
aff87d4372 create tracked object class and save thumbnails 2021-01-26 21:40:33 -06:00
Blake Blackshear
3a3cb24631 naming threads and processes for logs 2021-01-26 21:40:33 -06:00