From c2a32bd6c15eaa3048bb9aa30af25b14344e8329 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 23 Mar 2024 13:45:15 -0600 Subject: [PATCH] Make saving preview frames on restart more reliable (#10630) * increase priority of saving preview frames * Improve checking for ended recording --- frigate/output/output.py | 4 ++-- frigate/record/maintainer.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frigate/output/output.py b/frigate/output/output.py index b7a918cd2..348d4ba7a 100644 --- a/frigate/output/output.py +++ b/frigate/output/output.py @@ -130,6 +130,8 @@ def output_frames( previous_frames[camera] = frame_time + move_preview_frames("clips") + while True: (topic, data) = detection_subscriber.get_data(timeout=0) @@ -156,8 +158,6 @@ def output_frames( for preview in preview_recorders.values(): preview.stop() - move_preview_frames("clips") - if birdseye is not None: birdseye.stop() diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index 98030814f..5a4fc1e49 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -7,6 +7,7 @@ import os import random import string import threading +import time from collections import defaultdict from multiprocessing.synchronize import Event as MpEvent from pathlib import Path @@ -440,7 +441,12 @@ class RecordingMaintainer(threading.Thread): def run(self) -> None: # Check for new files every 5 seconds wait_time = 0.0 - while not self.stop_event.wait(wait_time): + while not self.stop_event.is_set(): + time.sleep(wait_time) + + if self.stop_event.is_set(): + break + run_start = datetime.datetime.now().timestamp() # check if there is an updated config