Compare commits

..
Author SHA1 Message Date
Nicolas Mowen 0a5a75204a Catch 2026-11-21 07:46:35 -07:00
Nicolas Mowen 07d7f723b8 Implement shared function to ensure consistency of object severity 2026-11-21 07:33:00 -07:00
Josh HawkinsandGitHub ce5b26dc11 Add summary timeline to Motion Review and History (#25034)
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
* add motion summary timeline to motion review and history

The summary strip draws motion as a canvas layer, with each pixel row's opacity set by the mean motion value over its time, so the full day is visible next to the 30s timeline. Dragging now converts strip pixels to timeline pixels directly instead of going through the drag box height, which no longer matches the box once it has borders. The strip is wider on mobile, and the drag box style is shared with the alerts and detections strips.

* hide summary timeline when motion only switch is on

* drag summary timeline from anywhere and keep a minimum box size

The drag box shrank to a few pixels when the timeline was zoomed in, and tapping the summary timeline on mobile read touches[0] on touchend, where the list is always empty. The box now has a minimum height centered on the visible range, and input goes through pointer events: a tap outside the box jumps there, and a press outside the box that moves snaps the box under the pointer and drags it.
2026-11-20 09:56:01 -06:00
d85527ffd2 Miscellaneous Fixes (#25027)
* Fix GenAI structured response not handling optional fields correctly

* allow export thumbnails for camera-restricted roles

Export thumbnails under /clips/export/ weren't classified by media auth, so roles with a camera allow-list got a 403 on every thumbnail. The thumbnail now resolves to its export's camera through a thumb_path lookup, and the camera access check applies as usual.

* load i18n locales from the base url

The locale load path was relative, so any URL with a trailing slash or more than one segment (like /admin/) fetched locales from under that path, got index.html back from the nginx fallback, and broke every UI string. Locales now load from the same base url as the API, which also covers HA ingress and FRIGATE_BASE_PATH.

* make storage retained-segment test able to fail

The old test put the retained segments after 59 older unretained ones, so cleanup freed its hourly target and stopped before it ever reached them. It passed even with the retention check removed. Retained segments now come first, and cleanup needs every unretained segment after them, so it has to skip the retained ones to finish.

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
2026-11-20 07:59:53 -06:00
Nicolas MowenandGitHub 4b1ae76baa Support HEIC images for Face Recognition (#25024)
CI / AMD64 Build (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
2026-11-19 08:09:59 -07:00
16 changed files with 855 additions and 348 deletions
+16 -6
View File
@@ -17,10 +17,10 @@ import re
from enum import Enum
from urllib.parse import unquote
from peewee import DoesNotExist
from peewee import DoesNotExist, Field
from frigate.config import FrigateConfig
from frigate.const import EXPORT_DIR
from frigate.const import CLIPS_DIR, EXPORT_DIR
from frigate.models import Export, User
logger = logging.getLogger(__name__)
@@ -151,6 +151,7 @@ def _resolve_clip(
# /clips/thumbs/{cam}/... → camera
# /clips/previews/{cam}/... → camera
# /clips/review/thumb-{cam}-{review_id}.webp → camera (parsed)
# /clips/export/{export_id}.{ext} → camera (DB lookup)
# /clips/faces/... → admin-only
# /clips/genai-requests/... → admin-only
# /clips/preview_restart_cache/... → admin-only
@@ -175,6 +176,11 @@ def _resolve_clip(
return MediaAuthResolution.CAMERA, camera
return MediaAuthResolution.UNRESOLVED_MEDIA, None
if second == "export" and len(parts) == 3:
return _export_camera(
Export.thumb_path, os.path.join(CLIPS_DIR, "export", parts[2])
)
if second in ("faces", "genai-requests", "preview_restart_cache"):
return MediaAuthResolution.ADMIN_ONLY, None
@@ -234,15 +240,19 @@ def _resolve_export(
if len(parts) != 2:
return MediaAuthResolution.UNRESOLVED_MEDIA, None
filename = parts[1]
full_path = os.path.join(EXPORT_DIR, filename)
return _export_camera(Export.video_path, os.path.join(EXPORT_DIR, parts[1]))
def _export_camera(
field: Field, full_path: str
) -> tuple[MediaAuthResolution, str | None]:
try:
export = Export.get(Export.video_path == full_path)
export = Export.get(field == full_path)
return MediaAuthResolution.CAMERA, export.camera
except DoesNotExist:
return MediaAuthResolution.UNRESOLVED_MEDIA, None
except Exception as e:
logger.warning("Export DB lookup failed for %s: %s", filename, e)
logger.warning("Export DB lookup failed for %s: %s", full_path, e)
return MediaAuthResolution.UNRESOLVED_MEDIA, None
+1
View File
@@ -42,6 +42,7 @@ def should_update_db(prev_event: dict[str, Any], current_event: dict[str, Any])
or prev_event["recognized_license_plate"]
!= current_event["recognized_license_plate"]
or prev_event["path_data"] != current_event["path_data"]
or prev_event["max_severity"] != current_event["max_severity"]
):
return True
return False
+26 -7
View File
@@ -187,16 +187,35 @@ def build_review_description_response_format(concerns: list[str]) -> dict[str, A
Strips the `time` field (populated server-side) and drops
`other_concerns` when no concerns are configured.
Every remaining property must be listed in `required` because strict
providers (OpenAI) reject a schema with any optional property.
"""
schema = ReviewMetadata.model_json_schema()
schema.get("properties", {}).pop("time", None)
properties = schema.setdefault("properties", {})
required = schema.setdefault("required", [])
properties.pop("time", None)
if "time" in schema.get("required", []):
schema["required"].remove("time")
if not concerns:
schema.get("properties", {}).pop("other_concerns", None)
if "other_concerns" in schema.get("required", []):
schema["required"].remove("other_concerns")
if "time" in required:
required.remove("time")
if concerns:
# The model field is nullable with a default so stored metadata
# without concerns still parses. For generation, require a plain list
# instead; the model returns an empty list when no concern applies.
properties["other_concerns"] = {
"type": "array",
"items": {"type": "string"},
"description": properties["other_concerns"]["description"],
}
if "other_concerns" not in required:
required.append("other_concerns")
else:
properties.pop("other_concerns", None)
if "other_concerns" in required:
required.remove("other_concerns")
return {
"type": "json_schema",
+13 -48
View File
@@ -30,6 +30,7 @@ from frigate.const import (
UPSERT_REVIEW_SEGMENT,
)
from frigate.models import ReviewSegment
from frigate.review.severity import get_review_severity
from frigate.review.types import SeverityEnum
from frigate.track.object_processing import ManualEventState
from frigate.util.image import SharedMemoryFrameManager, calculate_16_9_crop
@@ -217,57 +218,21 @@ class ActiveObjects:
}
for o in all_objects:
if (
o["motionless_count"] >= camera_config.detect.stationary.threshold
and not o["pending_loitering"]
):
# no stationary objects unless loitering
continue
severity = get_review_severity(
camera_config,
label=o["label"],
current_zones=o["current_zones"],
false_positive=o["false_positive"],
detected=o["frame_time"] == frame_time,
position_changes=o["position_changes"],
motionless_count=o["motionless_count"],
pending_loitering=o["pending_loitering"],
)
if o["position_changes"] == 0:
# object must have moved at least once
continue
if o["frame_time"] != frame_time:
# object must be detected in this frame
continue
if o["false_positive"]:
# object must not be a false positive
continue
if (
o["label"] in camera_config.review.alerts.labels
and (
not camera_config.review.alerts.required_zones
or (
len(o["current_zones"]) > 0
and set(o["current_zones"])
& set(camera_config.review.alerts.required_zones)
)
)
and camera_config.review.alerts.enabled
):
if severity == SeverityEnum.alert:
self.categorized_objects["alerts"].append(o)
continue
if (
(
camera_config.review.detections.labels is None
or o["label"] in camera_config.review.detections.labels
)
and (
not camera_config.review.detections.required_zones
or (
len(o["current_zones"]) > 0
and set(o["current_zones"])
& set(camera_config.review.detections.required_zones)
)
)
and camera_config.review.detections.enabled
):
elif severity == SeverityEnum.detection:
self.categorized_objects["detections"].append(o)
continue
def has_active_objects(self) -> bool:
return (
+80
View File
@@ -0,0 +1,80 @@
"""Rules for which review severity a tracked object qualifies for."""
from typing import cast
from frigate.config import CameraConfig
from frigate.review.types import SeverityEnum
def get_review_severity(
camera_config: CameraConfig,
*,
label: str,
current_zones: list[str],
false_positive: bool,
detected: bool,
position_changes: int,
motionless_count: int,
pending_loitering: bool,
) -> SeverityEnum | None:
"""Get the review severity a tracked object qualifies for on the current frame.
Review segments and a tracked object's max_severity both use this, so an
object is only reported as an alert or detection when it could actually
create or extend a review segment of that severity.
Args:
camera_config: Config for the camera the object is on
label: The object's label
current_zones: Zones the object is in on the current frame
false_positive: Whether the object is still considered a false positive
detected: Whether the object was detected on the current frame
position_changes: Number of times the object has changed position
motionless_count: Number of frames the object has not moved
pending_loitering: Whether the object is in a loitering zone but has
not met the loitering time yet
Returns:
The severity the object qualifies for, or None if it does not qualify
"""
# always populated from detect fps when the config is loaded
stationary_threshold = cast(int, camera_config.detect.stationary.threshold)
# stationary objects don't count unless they are loitering
if motionless_count >= stationary_threshold and not pending_loitering:
return None
# object must have moved at least once
if position_changes == 0:
return None
if not detected or false_positive:
return None
review_config = camera_config.review
zones = set(current_zones)
if (
review_config.alerts.enabled
and label in review_config.alerts.labels
and (
not review_config.alerts.required_zones
or zones & set(review_config.alerts.required_zones)
)
):
return SeverityEnum.alert
if (
review_config.detections.enabled
and (
review_config.detections.labels is None
or label in review_config.detections.labels
)
and (
not review_config.detections.required_zones
or zones & set(review_config.detections.required_zones)
)
):
return SeverityEnum.detection
return None
@@ -0,0 +1,42 @@
"""When tracked object updates are written to the database."""
import unittest
from typing import Any
from frigate.events.maintainer import should_update_db
def _event(**overrides: Any) -> dict[str, Any]:
return {
"end_time": None,
"has_clip": False,
"has_snapshot": True,
"top_score": 0.8,
"entered_zones": ["porch"],
"average_estimated_speed": 0,
"velocity_angle": 0,
"recognized_license_plate": None,
"path_data": [],
"max_severity": None,
**overrides,
}
class TestShouldUpdateDb(unittest.TestCase):
def test_unchanged_saved_event_is_not_updated(self):
self.assertFalse(should_update_db(_event(), _event()))
def test_max_severity_change_updates_saved_event(self):
self.assertTrue(should_update_db(_event(), _event(max_severity="alert")))
def test_max_severity_change_ignored_when_not_saved(self):
self.assertFalse(
should_update_db(
_event(has_snapshot=False),
_event(has_snapshot=False, max_severity="alert"),
)
)
if __name__ == "__main__":
unittest.main()
+36
View File
@@ -7,11 +7,47 @@ from frigate.genai.prompts import (
REVIEW_DESCRIPTION_FIELD_GUIDELINES,
REVIEW_RESPONSE_STYLES,
build_review_description_prompt,
build_review_description_response_format,
build_review_summary_prompt,
get_review_field_guidelines,
)
class TestReviewDescriptionResponseFormat(unittest.TestCase):
def _schema(self, concerns: list[str]) -> dict:
response_format = build_review_description_response_format(concerns)
self.assertTrue(response_format["json_schema"]["strict"])
return response_format["json_schema"]["schema"]
def test_every_property_is_required_for_strict_mode(self):
for concerns in ([], ["a person loitering near the gate"]):
with self.subTest(concerns=concerns):
schema = self._schema(concerns)
self.assertEqual(set(schema["properties"]), set(schema["required"]))
def test_time_is_never_requested(self):
schema = self._schema(["a person loitering near the gate"])
self.assertNotIn("time", schema["properties"])
self.assertNotIn("time", schema["required"])
def test_concerns_omitted_when_not_configured(self):
schema = self._schema([])
self.assertNotIn("other_concerns", schema["properties"])
self.assertNotIn("other_concerns", schema["required"])
def test_concerns_requested_as_plain_list_when_configured(self):
schema = self._schema(["a person loitering near the gate"])
concerns = schema["properties"]["other_concerns"]
self.assertEqual(concerns["type"], "array")
self.assertEqual(concerns["items"], {"type": "string"})
self.assertNotIn("anyOf", concerns)
self.assertNotIn("default", concerns)
def test_schema_is_not_shared_between_calls(self):
self._schema(["a person loitering near the gate"])
self.assertNotIn("other_concerns", self._schema([])["properties"])
class TestReviewResponseStyle(unittest.TestCase):
def _build_prompt(self, response_style: str = "default") -> str:
review_data = {
+30 -2
View File
@@ -20,7 +20,7 @@ from frigate.api.media_auth import (
resolve_media_uri,
)
from frigate.config import FrigateConfig
from frigate.const import EXPORT_DIR
from frigate.const import CLIPS_DIR, EXPORT_DIR
from frigate.models import Event, Export, Recordings, ReviewSegment
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS, TEST_DB_PRAGMAS
@@ -247,7 +247,7 @@ class TestExportResolution(unittest.TestCase):
name=f"export-{export_id}",
date=int(datetime.datetime.now().timestamp()),
video_path=os.path.join(EXPORT_DIR, filename),
thumb_path=os.path.join(EXPORT_DIR, f"{filename}.jpg"),
thumb_path=os.path.join(CLIPS_DIR, "export", f"{export_id}.webp"),
in_progress=False,
).execute()
@@ -280,6 +280,34 @@ class TestExportResolution(unittest.TestCase):
resolution, _ = resolve_media_uri("/exports/clip.mp4", self.config)
self.assertEqual(resolution, MediaAuthResolution.UNRESOLVED_MEDIA)
def test_export_thumbnail_resolves_camera(self):
self._insert_export("back_door_abc123", "back_door", "back_door_clip.mp4")
resolution, camera = resolve_media_uri(
"/clips/export/back_door_abc123.webp", self.config
)
self.assertEqual(resolution, MediaAuthResolution.CAMERA)
self.assertEqual(camera, "back_door")
def test_unknown_export_thumbnail_is_unresolved(self):
resolution, _ = resolve_media_uri("/clips/export/missing.webp", self.config)
self.assertEqual(resolution, MediaAuthResolution.UNRESOLVED_MEDIA)
def test_export_thumbnail_gated_by_camera_access(self):
self._insert_export("back_door_abc123", "back_door", "back_door_clip.mp4")
self._insert_export("front_door_def456", "front_door", "front_door_clip.mp4")
url = "/clips/export/{}.webp"
self.assertIsNone(
deny_response_for_media_uri(
url.format("front_door_def456"), "limited_user", self.config
)
)
self.assertEqual(
deny_response_for_media_uri(
url.format("back_door_abc123"), "limited_user", self.config
),
403,
)
class TestDenyResponseForMediaUri(unittest.TestCase):
"""End-to-end decision check used by /auth."""
+253
View File
@@ -0,0 +1,253 @@
"""Review severity rules shared by review segments and tracked objects."""
import unittest
from typing import Any
from frigate.config import FrigateConfig
from frigate.review.maintainer import ActiveObjects
from frigate.review.severity import get_review_severity
from frigate.review.types import SeverityEnum
from frigate.track.tracked_object import TrackedObject
CAMERA = "cam"
FPS = 5
ZONE = "porch"
INSIDE_X = 480
OUTSIDE_X = 160
def _config(alerts_enabled: bool = True) -> FrigateConfig:
return FrigateConfig(
**{
"mqtt": {"enabled": False},
"cameras": {
CAMERA: {
"ffmpeg": {
"inputs": [
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
]
},
"detect": {"width": 640, "height": 480, "fps": FPS},
"objects": {"track": ["person"]},
"zones": {ZONE: {"coordinates": "0.5,0,1,0,1,1,0.5,1"}},
"review": {
"alerts": {
"enabled": alerts_enabled,
"required_zones": [ZONE],
}
},
}
},
}
)
class TestGetReviewSeverity(unittest.TestCase):
def setUp(self):
self.camera_config = _config().cameras[CAMERA]
self.stationary_threshold = self.camera_config.detect.stationary.threshold
def _severity(self, camera_config=None, **overrides: Any) -> SeverityEnum | None:
kwargs = {
"label": "person",
"current_zones": [ZONE],
"false_positive": False,
"detected": True,
"position_changes": 1,
"motionless_count": 0,
"pending_loitering": False,
**overrides,
}
return get_review_severity(camera_config or self.camera_config, **kwargs)
def test_alert_in_required_zone(self):
self.assertEqual(self._severity(), SeverityEnum.alert)
def test_detection_outside_alert_required_zone(self):
self.assertEqual(self._severity(current_zones=[]), SeverityEnum.detection)
def test_detection_when_alerts_disabled(self):
camera_config = _config(alerts_enabled=False).cameras[CAMERA]
self.assertEqual(
self._severity(camera_config=camera_config), SeverityEnum.detection
)
def test_stationary_object_does_not_qualify(self):
self.assertIsNone(self._severity(motionless_count=self.stationary_threshold))
def test_stationary_loitering_object_qualifies(self):
self.assertEqual(
self._severity(
motionless_count=self.stationary_threshold, pending_loitering=True
),
SeverityEnum.alert,
)
def test_object_that_never_moved_does_not_qualify(self):
self.assertIsNone(self._severity(position_changes=0))
def test_undetected_object_does_not_qualify(self):
self.assertIsNone(self._severity(detected=False))
def test_false_positive_does_not_qualify(self):
self.assertIsNone(self._severity(false_positive=True))
class TestTrackedObjectMaxSeverity(unittest.TestCase):
"""max_severity must match what review segments would have been created."""
def setUp(self):
config = _config()
self.camera_config = config.cameras[CAMERA]
self.stationary_threshold = self.camera_config.detect.stationary.threshold
self.frame = 0
self.position_changes = 0
self.motionless_count = 0
self.last_detection = self._obj_data(OUTSIDE_X, 0.6, 1000.0)
self.obj = TrackedObject(
config.model_for_camera(CAMERA),
self.camera_config,
config.ui,
{},
{**self.last_detection, "score_history": [0.6]},
)
def _obj_data(self, x: int, score: float, frame_time: float) -> dict[str, Any]:
return {
"id": "1000.0-abcdef",
"label": "person",
"frame_time": frame_time,
"start_time": 1000.0,
"score": score,
"box": (x - 40, 200, x + 40, 360),
"area": 12800,
"ratio": 0.5,
"region": (0, 0, 640, 480),
"centroid": (x, 280),
"position_changes": self.position_changes,
"motionless_count": self.motionless_count,
"attributes": [],
"sub_label": None,
}
def _step(
self, x: int, score: float, moved: bool, detected: bool = True
) -> SeverityEnum | None:
"""Advance one frame and return the severity review segments would see."""
self.frame += 1
frame_time = 1000.0 + self.frame / FPS
if detected:
# mirror the tracker, which counts the first move and any move
# after the object was stationary as a position change
if moved:
if (
self.position_changes == 0
or self.motionless_count >= self.stationary_threshold
):
self.position_changes += 1
self.motionless_count = 0
else:
self.motionless_count += 1
self.last_detection = self._obj_data(x, score, frame_time)
_, self.last_significant, _, _ = self.obj.update(
frame_time, dict(self.last_detection), False
)
activity = ActiveObjects(frame_time, self.camera_config, [self.obj.to_dict()])
if activity.has_activity_category(SeverityEnum.alert):
return SeverityEnum.alert
if activity.has_activity_category(SeverityEnum.detection):
return SeverityEnum.detection
return None
def test_object_confirmed_while_stationary_in_zone_has_no_severity(self):
"""An object that only becomes a true positive after it stopped moving
never creates a review, so it must not be reported as an alert even
though it entered a required zone."""
review_severities = []
# walks into the zone with a low score, so it is a false positive
for i in range(10):
review_severities.append(self._step(OUTSIDE_X + i * 40, 0.6, moved=True))
# sits still until it is stationary
for _ in range(self.stationary_threshold):
review_severities.append(self._step(INSIDE_X, 0.6, moved=False))
# a re-detection while still stationary confirms it as a true positive
for _ in range(10):
review_severities.append(self._step(INSIDE_X, 0.9, moved=False))
# leaves and is no longer detected
for _ in range(10):
review_severities.append(self._step(INSIDE_X, 0.9, False, detected=False))
self.assertFalse(self.obj.false_positive)
self.assertEqual(self.obj.obj_data["position_changes"], 1)
self.assertEqual(self.obj.entered_zones, [ZONE])
self.assertEqual(set(review_severities), {None})
self.assertIsNone(self.obj.max_severity)
self.assertIsNone(self.obj.to_dict()["max_severity"])
def test_severity_change_is_significant(self):
"""Confirming an object already moving in the zone changes nothing else
that is watched, but the new severity still has to be published."""
for i in range(10):
self._step(OUTSIDE_X + i * 40, 0.6, moved=True)
self.assertEqual(self.obj.current_zones, [ZONE])
self.assertIsNone(self.obj.max_severity)
for i in range(10):
self._step(INSIDE_X + (i % 2) * 10, 0.9, moved=True)
if self.obj.max_severity is not None:
break
self.assertEqual(self.obj.max_severity, SeverityEnum.alert)
self.assertTrue(self.last_significant)
self._step(INSIDE_X, 0.9, moved=True)
self.assertFalse(self.last_significant)
def test_alert_is_kept_after_object_stops_qualifying(self):
for i in range(10):
self._step(OUTSIDE_X + i * 40, 0.9, moved=True)
self.assertEqual(self.obj.current_zones, [ZONE])
self.assertEqual(self.obj.max_severity, SeverityEnum.alert)
for _ in range(self.stationary_threshold + 5):
self._step(INSIDE_X, 0.9, moved=False)
self.assertTrue(self.obj.is_stationary())
self.assertEqual(self.obj.max_severity, SeverityEnum.alert)
def test_detection_upgrades_to_alert_and_is_not_downgraded(self):
review_severities = []
for _ in range(8):
review_severities.append(self._step(OUTSIDE_X, 0.9, moved=True))
self.assertEqual(self.obj.max_severity, SeverityEnum.detection)
for _ in range(5):
review_severities.append(self._step(INSIDE_X, 0.9, moved=True))
self.assertEqual(self.obj.max_severity, SeverityEnum.alert)
for _ in range(5):
review_severities.append(self._step(OUTSIDE_X, 0.9, moved=True))
self.assertEqual(review_severities[-1], SeverityEnum.detection)
self.assertEqual(self.obj.max_severity, SeverityEnum.alert)
self.assertIn(SeverityEnum.alert, review_severities)
if __name__ == "__main__":
unittest.main()
+18 -40
View File
@@ -511,55 +511,33 @@ class TestHttp(unittest.TestCase):
Recordings.get(Recordings.id == rec_d3_id)
def test_storage_cleanup_keeps_retained(self):
"""Ensure that all recordings are cleaned up when necessary."""
"""Ensure cleanup steps over retained segments to reach newer ones."""
config = FrigateConfig(**self.minimal_config)
storage = StorageMaintainer(config, MagicMock())
id = "123456.keep"
time_keep = datetime.datetime.now().timestamp()
_insert_mock_event(
id,
time_keep,
time_keep + 30,
True,
)
rec_k_id = "1234567.keep"
rec_k2_id = "1234568.keep"
rec_k3_id = "1234569.keep"
_insert_mock_recording(
rec_k_id,
os.path.join(self.test_dir, f"{rec_k_id}.tmp"),
time_keep,
time_keep + 10,
)
_insert_mock_recording(
rec_k2_id,
os.path.join(self.test_dir, f"{rec_k2_id}.tmp"),
time_keep + 10,
time_keep + 20,
)
_insert_mock_recording(
rec_k3_id,
os.path.join(self.test_dir, f"{rec_k3_id}.tmp"),
time_keep + 20,
time_keep + 30,
)
seg_len = 600
base = datetime.datetime.now().timestamp() - 7200
_insert_mock_event("123456.keep", base, base + 2.5 * seg_len, True)
time_delete = datetime.datetime.now().timestamp() - 7200
for i in range(0, 59):
id = f"{123456 + i}.delete"
paths = {}
for i in range(10):
rec_id = f"segment-{i}"
paths[rec_id] = os.path.join(self.test_dir, f"{rec_id}.tmp")
_insert_mock_recording(
id,
os.path.join(self.test_dir, f"{id}.tmp"),
time_delete,
time_delete + 600,
rec_id, paths[rec_id], base + i * seg_len, base + (i + 1) * seg_len
)
# Hourly bandwidth is 48 MB, so cleanup needs all 56 MB of unretained
# segments and must pass the older retained ones to get there.
storage.calculate_camera_bandwidth()
storage.reduce_storage_consumption()
assert Recordings.get(Recordings.id == rec_k_id)
assert Recordings.get(Recordings.id == rec_k2_id)
assert Recordings.get(Recordings.id == rec_k3_id)
retained = {"segment-0", "segment-1", "segment-2"}
remaining = {r.id for r in Recordings.select(Recordings.id)}
on_disk = {rec_id for rec_id, path in paths.items() if os.path.exists(path)}
self.assertEqual(remaining, retained)
self.assertEqual(on_disk, retained)
self.assertFalse(storage.retention_unmet)
def test_unmet_retention_sets_the_live_flag(self):
config = FrigateConfig(**self.minimal_config)
+25 -30
View File
@@ -17,6 +17,7 @@ from frigate.config import (
)
from frigate.const import CLIPS_DIR, REPLAY_CAMERA_PREFIX, THUMB_DIR
from frigate.detectors.detector_config import ModelConfig
from frigate.review.severity import get_review_severity
from frigate.review.types import SeverityEnum
from frigate.util.builtin import sanitize_float
from frigate.util.image import (
@@ -69,6 +70,8 @@ class TrackedObject:
self.new_zone_entered: bool = False
self.attributes: dict[str, float] = defaultdict(float)
self.false_positive = True
# highest review severity the object qualified for on any frame
self.max_severity: SeverityEnum | None = None
self.has_clip = False
self.has_snapshot = False
self.top_score = self.computed_score = 0.0
@@ -85,36 +88,6 @@ class TrackedObject:
self.path_data: list[tuple[Any, float]] = []
self.previous = self.to_dict()
@property
def max_severity(self) -> str | None:
review_config = self.camera_config.review
if (
self.camera_config.review.alerts.enabled
and self.obj_data["label"] in review_config.alerts.labels
and (
not review_config.alerts.required_zones
or set(self.entered_zones) & set(review_config.alerts.required_zones)
)
):
return SeverityEnum.alert
if (
self.camera_config.review.detections.enabled
and (
not review_config.detections.labels
or self.obj_data["label"] in review_config.detections.labels
)
and (
not review_config.detections.required_zones
or set(self.entered_zones)
& set(review_config.detections.required_zones)
)
):
return SeverityEnum.detection
return None
def _is_false_positive(self) -> bool:
# once a true positive, always a true positive
if not self.false_positive:
@@ -386,6 +359,28 @@ class TrackedObject:
self.obj_data.update(obj_data)
self.current_zones = current_zones
# use the same per-frame rules as review segments, so max_severity is
# never alert or detection unless the object could create that review
severity = get_review_severity(
self.camera_config,
label=self.obj_data["label"],
current_zones=current_zones,
false_positive=self.false_positive,
detected=detected,
position_changes=self.obj_data["position_changes"],
motionless_count=self.obj_data["motionless_count"],
pending_loitering=self.pending_loitering,
)
if severity != self.max_severity and (
severity == SeverityEnum.alert
or (severity == SeverityEnum.detection and self.max_severity is None)
):
self.max_severity = severity
# max_severity is saved with the event, so publish the change
significant_change = True
logger.debug(
f"{self.camera_config.name}: Updating {obj_data['id']}: thumb update? {thumb_update}, significant change? {significant_change}, path update? {path_update}, autotracker update? {autotracker_update} "
)
@@ -28,7 +28,7 @@ export function SummarySegment({
<div className="absolute inset-0 flex h-full cursor-pointer justify-end">
<div
className={cn(
"w-[10px]",
"w-full",
severityColors[severity],
height < 0.5 && "min-h-[0.5px]",
)}
+210 -156
View File
@@ -8,18 +8,26 @@ import React, {
import { SummarySegment } from "./SummarySegment";
import {
ConsolidatedSegmentData,
MotionData,
ReviewSegment,
ReviewSeverity,
} from "@/types/review";
import { useTimelineUtils } from "@/hooks/use-timeline-utils";
import { cn } from "@/lib/utils";
import { isMobile } from "react-device-detect";
const MIN_BOX_HEIGHT = isMobile ? 20 : 12;
const DRAG_THRESHOLD = 4;
export type SummaryTimelineProps = {
reviewTimelineRef: React.RefObject<HTMLDivElement | null>;
timelineStart: number;
timelineEnd: number;
segmentDuration: number;
events: ReviewSegment[];
severityType: ReviewSeverity;
events?: ReviewSegment[];
severityType?: ReviewSeverity;
motionData?: MotionData[];
motionScale?: number;
};
export function SummaryTimeline({
@@ -27,16 +35,22 @@ export function SummaryTimeline({
timelineStart,
timelineEnd,
segmentDuration,
events,
events = [],
severityType,
motionData,
motionScale,
}: SummaryTimelineProps) {
const summaryTimelineRef = useRef<HTMLDivElement>(null);
const visibleSectionRef = useRef<HTMLDivElement>(null);
const motionCanvasRef = useRef<HTMLCanvasElement>(null);
const [isDragging, setIsDragging] = useState(false);
const [scrollStartPosition, setScrollStartPosition] = useState<number>(0);
const [initialReviewTimelineScrollTop, setInitialReviewTimelineScrollTop] =
useState<number>(0);
const dragRef = useRef<{
startY: number;
startScrollTop: number;
insideBox: boolean;
moved: boolean;
} | null>(null);
const observer = useRef<ResizeObserver | null>(null);
@@ -129,6 +143,79 @@ export function SummaryTimeline({
segmentDuration,
]);
// Each motion sample covers motionScale seconds with a 0-100 value, and
// bins without motion are absent. Opacity is the bucket's mean value.
const drawMotion = useCallback(() => {
const canvas = motionCanvasRef.current;
const ctx = canvas?.getContext("2d");
if (!canvas || !ctx || !motionData || !motionScale) {
return;
}
const { clientWidth: width, clientHeight: height } = canvas;
const dpr = window.devicePixelRatio || 1;
canvas.width = width * dpr;
canvas.height = height * dpr;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
ctx.clearRect(0, 0, width, height);
const duration = timelineStart - timelineEnd;
if (duration <= 0 || height <= 0) {
return;
}
const rows = Math.max(
1,
Math.min(Math.floor(height), Math.ceil(duration / motionScale)),
);
const rowHeight = height / rows;
const rowSeconds = duration / rows;
const sums = new Array<number>(rows).fill(0);
motionData.forEach((item) => {
const row = Math.floor(
((timelineStart - item.start_time) / duration) * rows,
);
if (row >= 0 && row < rows) {
sums[row] += item.motion ?? 0;
}
});
const color = getComputedStyle(document.documentElement)
.getPropertyValue("--severity_significant_motion")
.trim();
const samplesPerRow = rowSeconds / motionScale;
sums.forEach((sum, row) => {
if (sum == 0) {
return;
}
const intensity = Math.min(1, sum / (100 * samplesPerRow));
ctx.fillStyle = `hsl(${color} / ${intensity})`;
ctx.fillRect(0, row * rowHeight, width, Math.ceil(rowHeight));
});
}, [motionData, motionScale, timelineStart, timelineEnd]);
useEffect(() => {
const canvas = motionCanvasRef.current;
if (!canvas) {
return;
}
drawMotion();
const resizeObserver = new ResizeObserver(drawMotion);
resizeObserver.observe(canvas);
return () => resizeObserver.disconnect();
}, [drawMotion]);
const setVisibleSectionStyles = useCallback(() => {
if (
reviewTimelineRef.current &&
@@ -144,13 +231,22 @@ export function SummaryTimeline({
} = content;
const { clientHeight: summaryTimelineVisibleHeight } = summary;
visibleSectionRef.current.style.top = `${
summaryTimelineVisibleHeight * (scrolled / reviewTimelineFullHeight)
}px`;
visibleSectionRef.current.style.height = `${
reviewTimelineVisibleHeight *
(reviewTimelineVisibleHeight / reviewTimelineFullHeight)
}px`;
// The box keeps a minimum height so it stays visible when zoomed in,
// centered on the true visible range.
const trueHeight =
summaryTimelineVisibleHeight *
(reviewTimelineVisibleHeight / reviewTimelineFullHeight);
const trueTop =
summaryTimelineVisibleHeight * (scrolled / reviewTimelineFullHeight);
const height = Math.max(trueHeight, MIN_BOX_HEIGHT);
const top = Math.min(
Math.max(trueTop - (height - trueHeight) / 2, 0),
summaryTimelineVisibleHeight - height,
);
visibleSectionRef.current.style.top = `${top}px`;
visibleSectionRef.current.style.height = `${height}px`;
}
}, [reviewTimelineRef, summaryTimelineRef, visibleSectionRef]);
@@ -184,178 +280,137 @@ export function SummaryTimeline({
segmentDuration,
]);
const timelineClick = useCallback(
(
e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,
) => {
// prevent default only for mouse events
// to avoid chrome/android issues
if (e.nativeEvent instanceof MouseEvent) {
e.preventDefault();
const scrollTopForPosition = useCallback(
(clientY: number) => {
const timeline = reviewTimelineRef.current;
const summary = summaryTimelineRef.current;
if (!timeline || !summary) {
return 0;
}
e.stopPropagation();
let clientY;
if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) {
clientY = e.nativeEvent.touches[0].clientY;
} else if (e.nativeEvent instanceof MouseEvent) {
clientY = e.nativeEvent.clientY;
}
if (
clientY &&
reviewTimelineRef.current &&
summaryTimelineRef.current &&
visibleSectionRef.current
) {
const { clientHeight: summaryTimelineVisibleHeight } =
summaryTimelineRef.current;
const rect = summary.getBoundingClientRect();
const ratio = (clientY - rect.top) / rect.height;
return ratio * timeline.scrollHeight - timeline.clientHeight / 2;
},
[reviewTimelineRef],
);
const rect = summaryTimelineRef.current.getBoundingClientRect();
const summaryTimelineTop = rect.top;
const scrollTimelineTo = useCallback(
(top: number, behavior: ScrollBehavior = "auto") => {
const timeline = reviewTimelineRef.current;
const { scrollHeight: reviewTimelineHeight } =
reviewTimelineRef.current;
const { clientHeight: visibleSectionHeight } =
visibleSectionRef.current;
const visibleSectionOffset = -(visibleSectionHeight / 2);
const clickPercentage =
(clientY - summaryTimelineTop + visibleSectionOffset) /
summaryTimelineVisibleHeight;
reviewTimelineRef.current.scrollTo({
top: Math.floor(reviewTimelineHeight * clickPercentage),
behavior: "smooth",
if (timeline) {
const maxScrollTop = timeline.scrollHeight - timeline.clientHeight;
timeline.scrollTo({
top: Math.min(Math.max(top, 0), maxScrollTop),
behavior,
});
}
},
[reviewTimelineRef, summaryTimelineRef, visibleSectionRef],
[reviewTimelineRef],
);
const handleMouseDown = useCallback(
(
e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,
) => {
// prevent default only for mouse events
// to avoid chrome/android issues
if (e.nativeEvent instanceof MouseEvent) {
e.preventDefault();
}
e.stopPropagation();
setIsDragging(true);
// A press outside the box jumps there on release, or snaps the box under
// the pointer once it moves and then drags it.
let clientY;
if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) {
clientY = e.nativeEvent.touches[0].clientY;
} else if (e.nativeEvent instanceof MouseEvent) {
clientY = e.nativeEvent.clientY;
const handlePointerDown = useCallback(
(e: React.PointerEvent<HTMLDivElement>) => {
if (
e.button != 0 ||
!reviewTimelineRef.current ||
!visibleSectionRef.current
) {
return;
}
if (clientY && summaryTimelineRef.current && reviewTimelineRef.current) {
setScrollStartPosition(clientY);
setInitialReviewTimelineScrollTop(reviewTimelineRef.current.scrollTop);
}
},
[setIsDragging, summaryTimelineRef, reviewTimelineRef],
);
const handleMouseUp = useCallback(
(e: MouseEvent | TouchEvent) => {
e.preventDefault();
e.stopPropagation();
if (isDragging) {
setIsDragging(false);
}
e.currentTarget.setPointerCapture(e.pointerId);
const box = visibleSectionRef.current.getBoundingClientRect();
dragRef.current = {
startY: e.clientY,
startScrollTop: reviewTimelineRef.current.scrollTop,
insideBox: e.clientY >= box.top && e.clientY <= box.bottom,
moved: false,
};
},
[isDragging, setIsDragging],
[reviewTimelineRef],
);
const handleMouseMove = useCallback(
(e: MouseEvent | TouchEvent) => {
if (
summaryTimelineRef.current &&
reviewTimelineRef.current &&
visibleSectionRef.current
) {
// prevent default only for mouse events
// to avoid chrome/android issues
if (e instanceof MouseEvent) {
e.preventDefault();
const handlePointerMove = useCallback(
(e: React.PointerEvent<HTMLDivElement>) => {
const drag = dragRef.current;
const timeline = reviewTimelineRef.current;
const summary = summaryTimelineRef.current;
if (!drag || !timeline || !summary) {
return;
}
const deltaY = e.clientY - drag.startY;
if (!drag.moved) {
if (Math.abs(deltaY) < DRAG_THRESHOLD) {
return;
}
e.stopPropagation();
let clientY;
if ("TouchEvent" in window && e instanceof TouchEvent) {
clientY = e.touches[0].clientY;
} else if (e instanceof MouseEvent) {
clientY = e.clientY;
}
if (isDragging && clientY) {
const { clientHeight: summaryTimelineVisibleHeight } =
summaryTimelineRef.current;
const {
scrollHeight: reviewTimelineHeight,
clientHeight: reviewTimelineVisibleHeight,
} = reviewTimelineRef.current;
drag.moved = true;
setIsDragging(true);
const { clientHeight: visibleSectionHeight } =
visibleSectionRef.current;
const deltaY =
(clientY - scrollStartPosition) *
(summaryTimelineVisibleHeight / visibleSectionHeight);
const newScrollTop = Math.min(
initialReviewTimelineScrollTop + deltaY,
reviewTimelineHeight - reviewTimelineVisibleHeight,
);
reviewTimelineRef.current.scrollTop = newScrollTop;
if (!drag.insideBox) {
drag.startScrollTop = scrollTopForPosition(drag.startY);
}
}
scrollTimelineTo(
drag.startScrollTop +
deltaY * (timeline.scrollHeight / summary.clientHeight),
);
},
[
initialReviewTimelineScrollTop,
isDragging,
reviewTimelineRef,
scrollStartPosition,
],
[reviewTimelineRef, scrollTopForPosition, scrollTimelineTo],
);
const documentRef = useRef<Document | null>(document);
useEffect(() => {
const documentInstance = documentRef.current;
const handlePointerUp = useCallback(
(e: React.PointerEvent<HTMLDivElement>) => {
const drag = dragRef.current;
dragRef.current = null;
setIsDragging(false);
if (isDragging) {
documentInstance?.addEventListener("mousemove", handleMouseMove);
documentInstance?.addEventListener("touchmove", handleMouseMove);
documentInstance?.addEventListener("mouseup", handleMouseUp);
documentInstance?.addEventListener("touchend", handleMouseUp);
} else {
documentInstance?.removeEventListener("mousemove", handleMouseMove);
documentInstance?.removeEventListener("touchmove", handleMouseMove);
documentInstance?.removeEventListener("mouseup", handleMouseUp);
documentInstance?.removeEventListener("touchend", handleMouseUp);
}
return () => {
documentInstance?.removeEventListener("mousemove", handleMouseMove);
documentInstance?.removeEventListener("touchmove", handleMouseMove);
documentInstance?.removeEventListener("mouseup", handleMouseUp);
documentInstance?.removeEventListener("touchend", handleMouseUp);
};
}, [handleMouseMove, handleMouseUp, isDragging]);
if (drag && !drag.moved && !drag.insideBox) {
scrollTimelineTo(scrollTopForPosition(e.clientY), "smooth");
}
},
[scrollTopForPosition, scrollTimelineTo],
);
const handlePointerCancel = useCallback(() => {
dragRef.current = null;
setIsDragging(false);
}, []);
return (
<div
className={`no-scrollbar relative h-full select-none overflow-hidden border-l-[1px] border-neutral-700 bg-secondary`}
className={cn(
"no-scrollbar relative h-full touch-none select-none overflow-hidden border-l-[1px] border-neutral-700 bg-secondary",
isDragging ? "cursor-grabbing" : "cursor-pointer",
)}
role="scrollbar"
onPointerDown={handlePointerDown}
onPointerMove={handlePointerMove}
onPointerUp={handlePointerUp}
onPointerCancel={handlePointerCancel}
>
{motionData && (
<canvas
ref={motionCanvasRef}
className="pointer-events-none absolute inset-0 size-full"
/>
)}
<div
ref={summaryTimelineRef}
className="relative z-10 flex h-full flex-col-reverse"
onClick={timelineClick}
onTouchEnd={timelineClick}
>
{consolidatedSegments.map((segment, index) => (
<SummarySegment
@@ -367,11 +422,10 @@ export function SummaryTimeline({
</div>
<div
ref={visibleSectionRef}
onMouseDown={handleMouseDown}
onTouchStart={handleMouseDown}
className={`absolute z-20 w-full touch-none bg-primary/30 ${
isDragging ? "cursor-grabbing" : "cursor-grab"
}`}
className={cn(
"absolute z-20 w-full border-y border-primary/60 bg-primary/30 shadow-[0_0_0_1px_hsl(var(--background))]",
!isDragging && "cursor-grab",
)}
></div>
</div>
);
+2 -1
View File
@@ -2,6 +2,7 @@ import i18n, { t } from "i18next";
import { initReactI18next } from "react-i18next";
import HttpBackend from "i18next-http-backend";
import { EventType } from "@/types/search";
import { baseUrl } from "@/api/baseUrl";
export const getTranslatedLabel = (
label: string,
@@ -33,7 +34,7 @@ i18n
fallbackLng: "en", // use en if detected lng is not available
backend: {
loadPath: `locales/{{lng}}/{{ns}}.json?v=${import.meta.env.VITE_GIT_COMMIT_HASH || "unknown"}`,
loadPath: `${baseUrl}locales/{{lng}}/{{ns}}.json?v=${import.meta.env.VITE_GIT_COMMIT_HASH || "unknown"}`,
},
ns: [
+54 -29
View File
@@ -923,7 +923,7 @@ function DetectionReview({
)}
</div>
</div>
<div className="flex w-[65px] flex-row md:w-[110px]">
<div className="flex w-[73px] flex-row md:w-[110px]">
<div className="no-scrollbar relative w-[55px] md:w-[100px]">
{loading ? (
<Skeleton className="size-full" />
@@ -951,7 +951,7 @@ function DetectionReview({
/>
)}
</div>
<div className="w-[10px]">
<div className="w-[18px] md:w-[10px]">
{loading ? (
<Skeleton className="w-full" />
) : (
@@ -1013,6 +1013,7 @@ function MotionReview({
const segmentDuration = 30;
const { data: config } = useSWR<FrigateConfig>("config");
const allowedCameras = useAllowedCameras();
const motionTimelineRef = useRef<HTMLDivElement>(null);
const reviewCameras = useMemo(() => {
if (!config) {
@@ -1700,34 +1701,58 @@ function MotionReview({
</div>
</div>
{!selectedMotionPreviewCamera && (
<div className="no-scrollbar w-[55px] overflow-y-auto md:w-[100px]">
{motionData ? (
<MotionReviewTimeline
segmentDuration={segmentDuration}
timestampSpread={15}
timelineStart={timeRangeSegments.end}
timelineEnd={timeRangeSegments.start}
motionOnly={motionOnly}
showHandlebar
handlebarTime={currentTime}
setHandlebarTime={setCurrentTime}
events={reviewItems?.all ?? []}
motion_events={motionData ?? []}
contentRef={contentRef}
onHandlebarDraggingChange={(scrubbing) => {
if (playing && scrubbing) {
setPlaying(false);
}
<div
className={cn(
"flex flex-row",
motionOnly ? "w-[55px] md:w-[100px]" : "w-[73px] md:w-[110px]",
)}
>
<div className="no-scrollbar w-[55px] overflow-y-auto md:w-[100px]">
{motionData ? (
<MotionReviewTimeline
timelineRef={motionTimelineRef}
segmentDuration={segmentDuration}
timestampSpread={15}
timelineStart={timeRangeSegments.end}
timelineEnd={timeRangeSegments.start}
motionOnly={motionOnly}
showHandlebar
handlebarTime={currentTime}
setHandlebarTime={setCurrentTime}
events={reviewItems?.all ?? []}
motion_events={motionData ?? []}
contentRef={contentRef}
onHandlebarDraggingChange={(scrubbing) => {
if (playing && scrubbing) {
setPlaying(false);
}
setScrubbing(scrubbing);
}}
dense={isMobileOnly}
isZooming={false}
zoomDirection={null}
alwaysShowMotionLine={true}
/>
) : (
<Skeleton className="size-full" />
setScrubbing(scrubbing);
}}
dense={isMobileOnly}
isZooming={false}
zoomDirection={null}
alwaysShowMotionLine={true}
/>
) : (
<Skeleton className="size-full" />
)}
</div>
{!motionOnly && (
<div className="w-[18px] md:w-[10px]">
{motionData ? (
<SummaryTimeline
reviewTimelineRef={motionTimelineRef}
timelineStart={timeRangeSegments.end}
timelineEnd={timeRangeSegments.start}
segmentDuration={segmentDuration}
motionData={motionData}
motionScale={segmentDuration / 2}
/>
) : (
<Skeleton className="w-full" />
)}
</div>
)}
</div>
)}
+48 -28
View File
@@ -70,6 +70,7 @@ import { cn } from "@/lib/utils";
import { useFullscreen } from "@/hooks/use-fullscreen";
import { useTimezone } from "@/hooks/use-date-utils";
import { useTimelineZoom } from "@/hooks/use-timeline-zoom";
import SummaryTimeline from "@/components/timeline/SummaryTimeline";
import { useTranslation } from "react-i18next";
import { useTimelineUtils } from "@/hooks/use-timeline-utils";
import {
@@ -1317,14 +1318,14 @@ function Timeline({
isDesktop
? cn(
timelineType == "timeline"
? "w-[100px] flex-shrink-0"
? "w-[110px] flex-shrink-0"
: timelineType == "detail"
? "min-w-[20rem] max-w-[30%] flex-shrink-0 flex-grow-0 basis-[30rem] md:min-w-[20rem] md:max-w-[25%] lg:min-w-[30rem] lg:max-w-[33%]"
: "w-80 flex-shrink-0",
)
: cn(
timelineType == "timeline"
? "portrait:flex-grow landscape:w-[100px] landscape:flex-shrink-0"
? "portrait:flex-grow landscape:w-[128px] landscape:flex-shrink-0"
: timelineType == "detail"
? "portrait:flex-grow landscape:w-[19rem] landscape:flex-shrink-0"
: "portrait:flex-grow landscape:w-[19rem] landscape:flex-shrink-0",
@@ -1345,32 +1346,51 @@ function Timeline({
)}
{timelineType == "timeline" ? (
!isLoading ? (
<MotionReviewTimeline
timelineRef={selectedTimelineRef}
segmentDuration={zoomSettings.segmentDuration}
timestampSpread={zoomSettings.timestampSpread}
timelineStart={timeRange.before}
timelineEnd={timeRange.after}
showHandlebar={exportRange == undefined}
showExportHandles={exportRange != undefined}
exportStartTime={exportRange?.after}
exportEndTime={exportRange?.before}
setExportStartTime={setExportStartTime}
setExportEndTime={setExportEndTime}
handlebarTime={currentTime}
setHandlebarTime={setCurrentTime}
events={mainCameraReviewItems}
motion_events={motionData ?? []}
noRecordingRanges={noRecordings ?? []}
subOnlyRanges={subOnlyRanges}
contentRef={contentRef}
onHandlebarDraggingChange={setScrubbing}
isZooming={isZooming}
zoomDirection={zoomDirection}
onZoomChange={handleZoomChange}
possibleZoomLevels={possibleZoomLevels}
currentZoomLevel={currentZoomLevel}
/>
<div className="flex size-full flex-row">
<div className="relative h-full min-w-0 flex-1">
<MotionReviewTimeline
timelineRef={selectedTimelineRef}
segmentDuration={zoomSettings.segmentDuration}
timestampSpread={zoomSettings.timestampSpread}
timelineStart={timeRange.before}
timelineEnd={timeRange.after}
showHandlebar={exportRange == undefined}
showExportHandles={exportRange != undefined}
exportStartTime={exportRange?.after}
exportEndTime={exportRange?.before}
setExportStartTime={setExportStartTime}
setExportEndTime={setExportEndTime}
handlebarTime={currentTime}
setHandlebarTime={setCurrentTime}
events={mainCameraReviewItems}
motion_events={motionData ?? []}
noRecordingRanges={noRecordings ?? []}
subOnlyRanges={subOnlyRanges}
contentRef={contentRef}
onHandlebarDraggingChange={setScrubbing}
isZooming={isZooming}
zoomDirection={zoomDirection}
onZoomChange={handleZoomChange}
possibleZoomLevels={possibleZoomLevels}
currentZoomLevel={currentZoomLevel}
/>
</div>
<div
className={cn(
"flex-shrink-0",
isDesktop ? "w-[10px]" : "w-[28px]",
)}
>
<SummaryTimeline
reviewTimelineRef={selectedTimelineRef}
timelineStart={timeRange.before}
timelineEnd={timeRange.after}
segmentDuration={zoomSettings.segmentDuration}
motionData={motionData}
motionScale={Math.round(zoomSettings.segmentDuration / 2)}
/>
</div>
</div>
) : (
<Skeleton className="size-full" />
)