forked from Github/frigate
Limit shm frame count (#12363)
* Limited shm frame count (#12346) * Only keep 2x detect fps frames in SHM * Don't delete previous shm frames in output * Catch case where images do not exist * Ensure files are closed * Clear out all frames when shutting down * Correct the number of frames saved * Simplify empty shm error handling * Improve frame safety * Add handler logs when frame is None * Don't fail on cleanup * Cleanup logging * Update docs * Update calculation * Restore condition * Fix case where thumbnail is saved without frame * Adjust debug logs * Calculate best shm frame count * Fix shm count calculation * Catch missing frame * Formatting * Clarify docs * Catch none frame in autotracking
This commit is contained in:
@@ -357,16 +357,14 @@ class BirdsEyeFrameManager:
|
||||
frame = None
|
||||
channel_dims = None
|
||||
else:
|
||||
try:
|
||||
frame = self.frame_manager.get(
|
||||
f"{camera}{frame_time}", self.config.cameras[camera].frame_shape_yuv
|
||||
)
|
||||
except FileNotFoundError:
|
||||
# TODO: better frame management would prevent this edge case
|
||||
logger.warning(
|
||||
f"Unable to copy frame {camera}{frame_time} to birdseye."
|
||||
)
|
||||
frame = self.frame_manager.get(
|
||||
f"{camera}{frame_time}", self.config.cameras[camera].frame_shape_yuv
|
||||
)
|
||||
|
||||
if frame is None:
|
||||
logger.debug(f"Unable to copy frame {camera}{frame_time} to birdseye.")
|
||||
return
|
||||
|
||||
channel_dims = self.cameras[camera]["channel_dims"]
|
||||
|
||||
copy_yuv_to_position(
|
||||
|
||||
@@ -45,7 +45,6 @@ def output_frames(
|
||||
signal.signal(signal.SIGINT, receiveSignal)
|
||||
|
||||
frame_manager = SharedMemoryFrameManager()
|
||||
previous_frames = {}
|
||||
|
||||
# start a websocket server on 8082
|
||||
WebSocketWSGIHandler.http_version = "1.1"
|
||||
@@ -99,6 +98,10 @@ def output_frames(
|
||||
|
||||
frame = frame_manager.get(frame_id, config.cameras[camera].frame_shape_yuv)
|
||||
|
||||
if frame is None:
|
||||
logger.debug(f"Failed to get frame {frame_id} from SHM")
|
||||
continue
|
||||
|
||||
# send camera frame to ffmpeg process if websockets are connected
|
||||
if any(
|
||||
ws.environ["PATH_INFO"].endswith(camera) for ws in websocket_server.manager
|
||||
@@ -128,10 +131,6 @@ def output_frames(
|
||||
)
|
||||
preview_write_times[camera] = frame_time
|
||||
|
||||
# delete frames after they have been used for output
|
||||
if camera in previous_frames:
|
||||
frame_manager.delete(f"{camera}{previous_frames[camera]}")
|
||||
|
||||
# if another camera generated a preview,
|
||||
# check for any cameras that are currently offline
|
||||
# and need to generate a preview
|
||||
@@ -141,7 +140,7 @@ def output_frames(
|
||||
preview_recorders[camera].flag_offline(frame_time)
|
||||
preview_write_times[camera] = frame_time
|
||||
|
||||
previous_frames[camera] = frame_time
|
||||
frame_manager.close(frame_id)
|
||||
|
||||
move_preview_frames("clips")
|
||||
|
||||
@@ -161,7 +160,7 @@ def output_frames(
|
||||
|
||||
frame_id = f"{camera}{frame_time}"
|
||||
frame = frame_manager.get(frame_id, config.cameras[camera].frame_shape_yuv)
|
||||
frame_manager.delete(frame_id)
|
||||
frame_manager.close(frame_id)
|
||||
|
||||
detection_subscriber.stop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user