mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-02 17:12:16 +03:00
recreate review thumbnail directory before writing and log write failures
cleanup's remove_empty_directories() can rmdir an empty clips/review, after which thumbnail writes silently fail. Ensure the directory exists before both cv2.imwrite calls and check their return value
This commit is contained in:
@@ -115,9 +115,11 @@ class PendingReviewSegment:
|
|||||||
if self._frame is not None:
|
if self._frame is not None:
|
||||||
self.thumb_time = datetime.datetime.now().timestamp()
|
self.thumb_time = datetime.datetime.now().timestamp()
|
||||||
self.has_frame = True
|
self.has_frame = True
|
||||||
cv2.imwrite(
|
Path(self.frame_path).parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
if not cv2.imwrite(
|
||||||
self.frame_path, self._frame, [int(cv2.IMWRITE_WEBP_QUALITY), 60]
|
self.frame_path, self._frame, [int(cv2.IMWRITE_WEBP_QUALITY), 60]
|
||||||
)
|
):
|
||||||
|
logger.error("Failed to write review thumbnail to %s", self.frame_path)
|
||||||
|
|
||||||
def save_full_frame(self, camera_config: CameraConfig, frame: np.ndarray) -> None:
|
def save_full_frame(self, camera_config: CameraConfig, frame: np.ndarray) -> None:
|
||||||
color_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
color_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
||||||
@@ -128,9 +130,11 @@ class PendingReviewSegment:
|
|||||||
|
|
||||||
if self._frame is not None:
|
if self._frame is not None:
|
||||||
self.has_frame = True
|
self.has_frame = True
|
||||||
cv2.imwrite(
|
Path(self.frame_path).parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
if not cv2.imwrite(
|
||||||
self.frame_path, self._frame, [int(cv2.IMWRITE_WEBP_QUALITY), 60]
|
self.frame_path, self._frame, [int(cv2.IMWRITE_WEBP_QUALITY), 60]
|
||||||
)
|
):
|
||||||
|
logger.error("Failed to write review thumbnail to %s", self.frame_path)
|
||||||
|
|
||||||
def get_data(self, ended: bool) -> dict:
|
def get_data(self, ended: bool) -> dict:
|
||||||
end_time = None
|
end_time = None
|
||||||
|
|||||||
Reference in New Issue
Block a user