From e72573098241e0455f1c3c4de635cecf727be10f Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 3 Oct 2024 09:31:07 -0600 Subject: [PATCH] Fix shared memory frames being stuck when a camera capture crashed (#14140) * Fix shared memory frames being stuck when a camera capture crashed * Update ffmpeg build --- docker/main/install_deps.sh | 4 ++-- frigate/video.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/main/install_deps.sh b/docker/main/install_deps.sh index 2c52cf552..7c2c5fda2 100755 --- a/docker/main/install_deps.sh +++ b/docker/main/install_deps.sh @@ -44,7 +44,7 @@ if [[ "${TARGETARCH}" == "amd64" ]]; then wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux64-gpl-5.1.tar.xz" tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1 rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay - wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-19-12-51/ffmpeg-n7.0.2-18-g3e6cec1286-linux64-gpl-7.0.tar.xz" + wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-30-15-36/ffmpeg-n7.1-linux64-gpl-7.1.tar.xz" tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/7.0 --strip-components 1 rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/7.0/doc /usr/lib/ffmpeg/7.0/bin/ffplay fi @@ -56,7 +56,7 @@ if [[ "${TARGETARCH}" == "arm64" ]]; then wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz" tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1 rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay - wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-19-12-51/ffmpeg-n7.0.2-18-g3e6cec1286-linuxarm64-gpl-7.0.tar.xz" + wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-30-15-36/ffmpeg-n7.1-linuxarm64-gpl-7.1.tar.xz" tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/7.0 --strip-components 1 rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/7.0/doc /usr/lib/ffmpeg/7.0/bin/ffplay fi diff --git a/frigate/video.py b/frigate/video.py index a8514ae03..0f051b6b2 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -94,6 +94,7 @@ def capture_frames( ffmpeg_process, config: CameraConfig, shm_frame_count: int, + shm_frames: list[str], frame_shape, frame_manager: FrameManager, frame_queue, @@ -108,8 +109,6 @@ def capture_frames( skipped_eps = EventsPerSecond() skipped_eps.start() - shm_frames: list[str] = [] - while True: fps.value = frame_rate.eps() skipped_fps.value = skipped_eps.eps() @@ -154,10 +153,6 @@ def capture_frames( # if the queue is full, skip this frame skipped_eps.update() - # clear out frames - for frame in shm_frames: - frame_manager.delete(frame) - class CameraWatchdog(threading.Thread): def __init__( @@ -176,6 +171,7 @@ class CameraWatchdog(threading.Thread): self.camera_name = camera_name self.config = config self.shm_frame_count = shm_frame_count + self.shm_frames: list[str] = [] self.capture_thread = None self.ffmpeg_detect_process = None self.logpipe = LogPipe(f"ffmpeg.{self.camera_name}.detect") @@ -308,6 +304,7 @@ class CameraWatchdog(threading.Thread): self.capture_thread = CameraCapture( self.config, self.shm_frame_count, + self.shm_frames, self.ffmpeg_detect_process, self.frame_shape, self.frame_queue, @@ -348,6 +345,7 @@ class CameraCapture(threading.Thread): self, config: CameraConfig, shm_frame_count: int, + shm_frames: list[str], ffmpeg_process, frame_shape, frame_queue, @@ -359,6 +357,7 @@ class CameraCapture(threading.Thread): self.name = f"capture:{config.name}" self.config = config self.shm_frame_count = shm_frame_count + self.shm_frames = shm_frames self.frame_shape = frame_shape self.frame_queue = frame_queue self.fps = fps @@ -374,6 +373,7 @@ class CameraCapture(threading.Thread): self.ffmpeg_process, self.config, self.shm_frame_count, + self.shm_frames, self.frame_shape, self.frame_manager, self.frame_queue,