mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Update formatting
This commit is contained in:
parent
5cecaab48b
commit
55c9f3949e
@ -247,9 +247,9 @@ class AudioEventMaintainer(threading.Thread):
|
|||||||
|
|
||||||
def handle_detection(self, label: str, score: float) -> None:
|
def handle_detection(self, label: str, score: float) -> None:
|
||||||
if self.detections.get(label):
|
if self.detections.get(label):
|
||||||
self.detections[label][
|
self.detections[label]["last_detection"] = (
|
||||||
"last_detection"
|
datetime.datetime.now().timestamp()
|
||||||
] = datetime.datetime.now().timestamp()
|
)
|
||||||
else:
|
else:
|
||||||
self.requestor.send_data(f"{self.config.name}/audio/{label}", "ON")
|
self.requestor.send_data(f"{self.config.name}/audio/{label}", "ON")
|
||||||
|
|
||||||
|
|||||||
@ -115,12 +115,12 @@ PRESETS_HW_ACCEL_ENCODE_BIRDSEYE = {
|
|||||||
"preset-rk-h265": "ffmpeg -hide_banner {0} -c:v hevc_rkmpp -profile:v high {1}",
|
"preset-rk-h265": "ffmpeg -hide_banner {0} -c:v hevc_rkmpp -profile:v high {1}",
|
||||||
"default": "ffmpeg -hide_banner {0} -c:v libx264 -g 50 -profile:v high -level:v 4.1 -preset:v superfast -tune:v zerolatency {1}",
|
"default": "ffmpeg -hide_banner {0} -c:v libx264 -g 50 -profile:v high -level:v 4.1 -preset:v superfast -tune:v zerolatency {1}",
|
||||||
}
|
}
|
||||||
PRESETS_HW_ACCEL_ENCODE_BIRDSEYE[
|
PRESETS_HW_ACCEL_ENCODE_BIRDSEYE["preset-nvidia-h264"] = (
|
||||||
"preset-nvidia-h264"
|
PRESETS_HW_ACCEL_ENCODE_BIRDSEYE[FFMPEG_HWACCEL_NVIDIA]
|
||||||
] = PRESETS_HW_ACCEL_ENCODE_BIRDSEYE[FFMPEG_HWACCEL_NVIDIA]
|
)
|
||||||
PRESETS_HW_ACCEL_ENCODE_BIRDSEYE[
|
PRESETS_HW_ACCEL_ENCODE_BIRDSEYE["preset-nvidia-h265"] = (
|
||||||
"preset-nvidia-h265"
|
PRESETS_HW_ACCEL_ENCODE_BIRDSEYE[FFMPEG_HWACCEL_NVIDIA]
|
||||||
] = PRESETS_HW_ACCEL_ENCODE_BIRDSEYE[FFMPEG_HWACCEL_NVIDIA]
|
)
|
||||||
|
|
||||||
PRESETS_HW_ACCEL_ENCODE_TIMELAPSE = {
|
PRESETS_HW_ACCEL_ENCODE_TIMELAPSE = {
|
||||||
"preset-rpi-64-h264": "ffmpeg -hide_banner {0} -c:v h264_v4l2m2m -pix_fmt yuv420p {1}",
|
"preset-rpi-64-h264": "ffmpeg -hide_banner {0} -c:v h264_v4l2m2m -pix_fmt yuv420p {1}",
|
||||||
@ -136,9 +136,9 @@ PRESETS_HW_ACCEL_ENCODE_TIMELAPSE = {
|
|||||||
"preset-rk-h265": "ffmpeg -hide_banner {0} -c:v hevc_rkmpp -profile:v high {1}",
|
"preset-rk-h265": "ffmpeg -hide_banner {0} -c:v hevc_rkmpp -profile:v high {1}",
|
||||||
"default": "ffmpeg -hide_banner {0} -c:v libx264 -preset:v ultrafast -tune:v zerolatency {1}",
|
"default": "ffmpeg -hide_banner {0} -c:v libx264 -preset:v ultrafast -tune:v zerolatency {1}",
|
||||||
}
|
}
|
||||||
PRESETS_HW_ACCEL_ENCODE_TIMELAPSE[
|
PRESETS_HW_ACCEL_ENCODE_TIMELAPSE["preset-nvidia-h264"] = (
|
||||||
"preset-nvidia-h264"
|
PRESETS_HW_ACCEL_ENCODE_TIMELAPSE[FFMPEG_HWACCEL_NVIDIA]
|
||||||
] = PRESETS_HW_ACCEL_ENCODE_TIMELAPSE[FFMPEG_HWACCEL_NVIDIA]
|
)
|
||||||
|
|
||||||
# encoding of previews is only done on CPU due to comparable encode times and better quality from libx264
|
# encoding of previews is only done on CPU due to comparable encode times and better quality from libx264
|
||||||
PRESETS_HW_ACCEL_ENCODE_PREVIEW = {
|
PRESETS_HW_ACCEL_ENCODE_PREVIEW = {
|
||||||
|
|||||||
@ -917,9 +917,9 @@ def event_snapshot(id):
|
|||||||
else:
|
else:
|
||||||
response.headers["Cache-Control"] = "no-store"
|
response.headers["Cache-Control"] = "no-store"
|
||||||
if download:
|
if download:
|
||||||
response.headers[
|
response.headers["Content-Disposition"] = (
|
||||||
"Content-Disposition"
|
f"attachment; filename=snapshot-{id}.jpg"
|
||||||
] = f"attachment; filename=snapshot-{id}.jpg"
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@ -1106,9 +1106,9 @@ def event_clip(id):
|
|||||||
if download:
|
if download:
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
||||||
response.headers["Content-Length"] = os.path.getsize(clip_path)
|
response.headers["Content-Length"] = os.path.getsize(clip_path)
|
||||||
response.headers[
|
response.headers["X-Accel-Redirect"] = (
|
||||||
"X-Accel-Redirect"
|
f"/clips/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
||||||
] = f"/clips/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@ -1404,9 +1404,9 @@ def config():
|
|||||||
config["plus"] = {"enabled": current_app.plus_api.is_active()}
|
config["plus"] = {"enabled": current_app.plus_api.is_active()}
|
||||||
|
|
||||||
for detector, detector_config in config["detectors"].items():
|
for detector, detector_config in config["detectors"].items():
|
||||||
detector_config["model"][
|
detector_config["model"]["labelmap"] = (
|
||||||
"labelmap"
|
current_app.frigate_config.model.merged_labelmap
|
||||||
] = current_app.frigate_config.model.merged_labelmap
|
)
|
||||||
|
|
||||||
return jsonify(config)
|
return jsonify(config)
|
||||||
|
|
||||||
@ -1811,9 +1811,9 @@ def get_recordings_storage_usage():
|
|||||||
|
|
||||||
total_mb = recording_stats["total"]
|
total_mb = recording_stats["total"]
|
||||||
|
|
||||||
camera_usages: dict[
|
camera_usages: dict[str, dict] = (
|
||||||
str, dict
|
current_app.storage_maintainer.calculate_camera_usages()
|
||||||
] = current_app.storage_maintainer.calculate_camera_usages()
|
)
|
||||||
|
|
||||||
for camera_name in camera_usages.keys():
|
for camera_name in camera_usages.keys():
|
||||||
if camera_usages.get(camera_name, {}).get("usage"):
|
if camera_usages.get(camera_name, {}).get("usage"):
|
||||||
@ -2001,9 +2001,9 @@ def recording_clip(camera_name, start_ts, end_ts):
|
|||||||
if download:
|
if download:
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
|
||||||
response.headers["Content-Length"] = os.path.getsize(path)
|
response.headers["Content-Length"] = os.path.getsize(path)
|
||||||
response.headers[
|
response.headers["X-Accel-Redirect"] = (
|
||||||
"X-Accel-Redirect"
|
f"/cache/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
||||||
] = f"/cache/{file_name}" # nginx: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
@ -297,12 +297,12 @@ class PtzAutoTracker:
|
|||||||
self.ptz_metrics[camera][
|
self.ptz_metrics[camera][
|
||||||
"ptz_max_zoom"
|
"ptz_max_zoom"
|
||||||
].value = camera_config.onvif.autotracking.movement_weights[1]
|
].value = camera_config.onvif.autotracking.movement_weights[1]
|
||||||
self.intercept[
|
self.intercept[camera] = (
|
||||||
camera
|
camera_config.onvif.autotracking.movement_weights[2]
|
||||||
] = camera_config.onvif.autotracking.movement_weights[2]
|
)
|
||||||
self.move_coefficients[
|
self.move_coefficients[camera] = (
|
||||||
camera
|
camera_config.onvif.autotracking.movement_weights[3:]
|
||||||
] = camera_config.onvif.autotracking.movement_weights[3:]
|
)
|
||||||
else:
|
else:
|
||||||
camera_config.onvif.autotracking.enabled = False
|
camera_config.onvif.autotracking.enabled = False
|
||||||
self.ptz_metrics[camera]["ptz_autotracker_enabled"].value = False
|
self.ptz_metrics[camera]["ptz_autotracker_enabled"].value = False
|
||||||
@ -603,9 +603,9 @@ class PtzAutoTracker:
|
|||||||
) ** self.zoom_factor[camera]
|
) ** self.zoom_factor[camera]
|
||||||
|
|
||||||
if "original_target_box" not in self.tracked_object_metrics[camera]:
|
if "original_target_box" not in self.tracked_object_metrics[camera]:
|
||||||
self.tracked_object_metrics[camera][
|
self.tracked_object_metrics[camera]["original_target_box"] = (
|
||||||
"original_target_box"
|
self.tracked_object_metrics[camera]["target_box"]
|
||||||
] = self.tracked_object_metrics[camera]["target_box"]
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
self.tracked_object_metrics[camera]["valid_velocity"],
|
self.tracked_object_metrics[camera]["valid_velocity"],
|
||||||
|
|||||||
@ -126,9 +126,9 @@ class OnvifController:
|
|||||||
logger.debug(f"Onvif config for {camera_name}: {ptz_config}")
|
logger.debug(f"Onvif config for {camera_name}: {ptz_config}")
|
||||||
|
|
||||||
service_capabilities_request = ptz.create_type("GetServiceCapabilities")
|
service_capabilities_request = ptz.create_type("GetServiceCapabilities")
|
||||||
self.cams[camera_name][
|
self.cams[camera_name]["service_capabilities_request"] = (
|
||||||
"service_capabilities_request"
|
service_capabilities_request
|
||||||
] = service_capabilities_request
|
)
|
||||||
|
|
||||||
fov_space_id = next(
|
fov_space_id = next(
|
||||||
(
|
(
|
||||||
@ -244,9 +244,9 @@ class OnvifController:
|
|||||||
supported_features.append("zoom-r")
|
supported_features.append("zoom-r")
|
||||||
try:
|
try:
|
||||||
# get camera's zoom limits from onvif config
|
# get camera's zoom limits from onvif config
|
||||||
self.cams[camera_name][
|
self.cams[camera_name]["relative_zoom_range"] = (
|
||||||
"relative_zoom_range"
|
ptz_config.Spaces.RelativeZoomTranslationSpace[0]
|
||||||
] = ptz_config.Spaces.RelativeZoomTranslationSpace[0]
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
if (
|
if (
|
||||||
self.config.cameras[camera_name].onvif.autotracking.zooming
|
self.config.cameras[camera_name].onvif.autotracking.zooming
|
||||||
@ -263,9 +263,9 @@ class OnvifController:
|
|||||||
supported_features.append("zoom-a")
|
supported_features.append("zoom-a")
|
||||||
try:
|
try:
|
||||||
# get camera's zoom limits from onvif config
|
# get camera's zoom limits from onvif config
|
||||||
self.cams[camera_name][
|
self.cams[camera_name]["absolute_zoom_range"] = (
|
||||||
"absolute_zoom_range"
|
ptz_config.Spaces.AbsoluteZoomPositionSpace[0]
|
||||||
] = ptz_config.Spaces.AbsoluteZoomPositionSpace[0]
|
)
|
||||||
self.cams[camera_name]["zoom_limits"] = configs.ZoomLimits
|
self.cams[camera_name]["zoom_limits"] = configs.ZoomLimits
|
||||||
except Exception:
|
except Exception:
|
||||||
if self.config.cameras[camera_name].onvif.autotracking.zooming:
|
if self.config.cameras[camera_name].onvif.autotracking.zooming:
|
||||||
@ -282,9 +282,9 @@ class OnvifController:
|
|||||||
and configs.DefaultRelativePanTiltTranslationSpace is not None
|
and configs.DefaultRelativePanTiltTranslationSpace is not None
|
||||||
):
|
):
|
||||||
supported_features.append("pt-r-fov")
|
supported_features.append("pt-r-fov")
|
||||||
self.cams[camera_name][
|
self.cams[camera_name]["relative_fov_range"] = (
|
||||||
"relative_fov_range"
|
ptz_config.Spaces.RelativePanTiltTranslationSpace[fov_space_id]
|
||||||
] = ptz_config.Spaces.RelativePanTiltTranslationSpace[fov_space_id]
|
)
|
||||||
|
|
||||||
self.cams[camera_name]["features"] = supported_features
|
self.cams[camera_name]["features"] = supported_features
|
||||||
|
|
||||||
|
|||||||
@ -41,9 +41,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
assert self.default_ffmpeg == frigate_config.dict(exclude_unset=True)
|
assert self.default_ffmpeg == frigate_config.dict(exclude_unset=True)
|
||||||
|
|
||||||
def test_ffmpeg_hwaccel_preset(self):
|
def test_ffmpeg_hwaccel_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["hwaccel_args"] = (
|
||||||
"hwaccel_args"
|
"preset-rpi-64-h264"
|
||||||
] = "preset-rpi-64-h264"
|
)
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
assert "preset-rpi-64-h264" not in (
|
assert "preset-rpi-64-h264" not in (
|
||||||
@ -54,9 +54,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_ffmpeg_hwaccel_not_preset(self):
|
def test_ffmpeg_hwaccel_not_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["hwaccel_args"] = (
|
||||||
"hwaccel_args"
|
"-other-hwaccel args"
|
||||||
] = "-other-hwaccel args"
|
)
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
assert "-other-hwaccel args" in (
|
assert "-other-hwaccel args" in (
|
||||||
@ -64,9 +64,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_ffmpeg_hwaccel_scale_preset(self):
|
def test_ffmpeg_hwaccel_scale_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["hwaccel_args"] = (
|
||||||
"hwaccel_args"
|
"preset-nvidia-h264"
|
||||||
] = "preset-nvidia-h264"
|
)
|
||||||
self.default_ffmpeg["cameras"]["back"]["detect"] = {
|
self.default_ffmpeg["cameras"]["back"]["detect"] = {
|
||||||
"height": 1920,
|
"height": 1920,
|
||||||
"width": 2560,
|
"width": 2560,
|
||||||
@ -85,9 +85,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
def test_default_ffmpeg_input_arg_preset(self):
|
def test_default_ffmpeg_input_arg_preset(self):
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
|
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["input_args"] = (
|
||||||
"input_args"
|
"preset-rtsp-generic"
|
||||||
] = "preset-rtsp-generic"
|
)
|
||||||
frigate_preset_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_preset_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
frigate_preset_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_preset_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
@ -98,9 +98,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_ffmpeg_input_preset(self):
|
def test_ffmpeg_input_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["input_args"] = (
|
||||||
"input_args"
|
"preset-rtmp-generic"
|
||||||
] = "preset-rtmp-generic"
|
)
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
assert "preset-rtmp-generic" not in (
|
assert "preset-rtmp-generic" not in (
|
||||||
@ -131,9 +131,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_ffmpeg_output_record_preset(self):
|
def test_ffmpeg_output_record_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"]["record"] = (
|
||||||
"record"
|
"preset-record-generic-audio-aac"
|
||||||
] = "preset-record-generic-audio-aac"
|
)
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
assert "preset-record-generic-audio-aac" not in (
|
assert "preset-record-generic-audio-aac" not in (
|
||||||
@ -144,9 +144,9 @@ class TestFfmpegPresets(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_ffmpeg_output_record_not_preset(self):
|
def test_ffmpeg_output_record_not_preset(self):
|
||||||
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"][
|
self.default_ffmpeg["cameras"]["back"]["ffmpeg"]["output_args"]["record"] = (
|
||||||
"record"
|
"-some output"
|
||||||
] = "-some output"
|
)
|
||||||
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
frigate_config = FrigateConfig(**self.default_ffmpeg)
|
||||||
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
frigate_config.cameras["back"].create_ffmpeg_cmds()
|
||||||
assert "-some output" in (
|
assert "-some output" in (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user