From b03a3e9f5f5a5e97246e0e7176e1337bb4b779d4 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Tue, 1 Nov 2022 10:56:10 -0600 Subject: [PATCH 1/2] Catch case where segment is bad length --- frigate/record.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frigate/record.py b/frigate/record.py index 21e42dfc02..4b0b4ed156 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -169,6 +169,11 @@ def move_files(self): p = sp.run(ffprobe_cmd, capture_output=True) if p.returncode == 0 and p.stdout.decode(): duration = float(p.stdout.decode().strip()) + else: + duration = -1 + + # ensure duration is within expected length + if 0 < duration < 600: end_time = start_time + datetime.timedelta(seconds=duration) self.end_time_cache[cache_path] = (end_time, duration) else: From 21be8e0943b9229a509629c8d35d0d7014a1c031 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Tue, 1 Nov 2022 16:54:24 -0600 Subject: [PATCH 2/2] Log ffprobe error code and error --- frigate/record.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frigate/record.py b/frigate/record.py index 4b0b4ed156..51e4a9d704 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -177,6 +177,11 @@ def move_files(self): end_time = start_time + datetime.timedelta(seconds=duration) self.end_time_cache[cache_path] = (end_time, duration) else: + if duration == -1: + logger.warning( + f"Failed to probe corrupt segment {f}: {p.returncode} - {p.stderr}" + ) + logger.warning(f"Discarding a corrupt recording segment: {f}") Path(cache_path).unlink(missing_ok=True) continue