mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-10 15:25:43 +03:00
publish valid segment data in recording maintainer
This commit is contained in:
parent
250565eff6
commit
f9861d4060
@ -80,9 +80,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
[CameraConfigUpdateEnum.add, CameraConfigUpdateEnum.record],
|
[CameraConfigUpdateEnum.add, CameraConfigUpdateEnum.record],
|
||||||
)
|
)
|
||||||
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all.value)
|
self.detection_subscriber = DetectionSubscriber(DetectionTypeEnum.all.value)
|
||||||
self.recordings_publisher = RecordingsDataPublisher(
|
self.recordings_publisher = RecordingsDataPublisher()
|
||||||
RecordingsDataTypeEnum.recordings_available_through
|
|
||||||
)
|
|
||||||
|
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.object_recordings_info: dict[str, list] = defaultdict(list)
|
self.object_recordings_info: dict[str, list] = defaultdict(list)
|
||||||
@ -233,7 +231,8 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
recordings[0]["start_time"].timestamp()
|
recordings[0]["start_time"].timestamp()
|
||||||
if self.config.cameras[camera].record.enabled
|
if self.config.cameras[camera].record.enabled
|
||||||
else None,
|
else None,
|
||||||
)
|
),
|
||||||
|
RecordingsDataTypeEnum.recordings_available_through.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
recordings_to_insert: list[Optional[Recordings]] = await asyncio.gather(*tasks)
|
recordings_to_insert: list[Optional[Recordings]] = await asyncio.gather(*tasks)
|
||||||
@ -250,7 +249,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
|
|
||||||
async def validate_and_move_segment(
|
async def validate_and_move_segment(
|
||||||
self, camera: str, reviews: list[ReviewSegment], recording: dict[str, Any]
|
self, camera: str, reviews: list[ReviewSegment], recording: dict[str, Any]
|
||||||
) -> None:
|
) -> Optional[Recordings]:
|
||||||
cache_path: str = recording["cache_path"]
|
cache_path: str = recording["cache_path"]
|
||||||
start_time: datetime.datetime = recording["start_time"]
|
start_time: datetime.datetime = recording["start_time"]
|
||||||
record_config = self.config.cameras[camera].record
|
record_config = self.config.cameras[camera].record
|
||||||
@ -261,7 +260,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
or not self.config.cameras[camera].record.enabled
|
or not self.config.cameras[camera].record.enabled
|
||||||
):
|
):
|
||||||
self.drop_segment(cache_path)
|
self.drop_segment(cache_path)
|
||||||
return
|
return None
|
||||||
|
|
||||||
if cache_path in self.end_time_cache:
|
if cache_path in self.end_time_cache:
|
||||||
end_time, duration = self.end_time_cache[cache_path]
|
end_time, duration = self.end_time_cache[cache_path]
|
||||||
@ -270,10 +269,14 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
self.config.ffmpeg, cache_path, get_duration=True
|
self.config.ffmpeg, cache_path, get_duration=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if segment_info["duration"]:
|
if not segment_info.get("has_valid_video", False):
|
||||||
duration = float(segment_info["duration"])
|
logger.warning(
|
||||||
else:
|
f"Invalid or missing video stream in segment {cache_path}. Discarding."
|
||||||
duration = -1
|
)
|
||||||
|
self.drop_segment(cache_path)
|
||||||
|
return None
|
||||||
|
|
||||||
|
duration = float(segment_info.get("duration", -1))
|
||||||
|
|
||||||
# ensure duration is within expected length
|
# ensure duration is within expected length
|
||||||
if 0 < duration < MAX_SEGMENT_DURATION:
|
if 0 < duration < MAX_SEGMENT_DURATION:
|
||||||
@ -284,8 +287,14 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
logger.warning(f"Failed to probe corrupt segment {cache_path}")
|
logger.warning(f"Failed to probe corrupt segment {cache_path}")
|
||||||
|
|
||||||
logger.warning(f"Discarding a corrupt recording segment: {cache_path}")
|
logger.warning(f"Discarding a corrupt recording segment: {cache_path}")
|
||||||
Path(cache_path).unlink(missing_ok=True)
|
self.drop_segment(cache_path)
|
||||||
return
|
return None
|
||||||
|
|
||||||
|
# this segment has a valid duration and has video data, so publish an update
|
||||||
|
self.recordings_publisher.publish(
|
||||||
|
(camera, start_time.timestamp(), cache_path),
|
||||||
|
RecordingsDataTypeEnum.latest_valid_segment.value,
|
||||||
|
)
|
||||||
|
|
||||||
record_config = self.config.cameras[camera].record
|
record_config = self.config.cameras[camera].record
|
||||||
highest = None
|
highest = None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user