Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

restart faster, sleep less before export

Rory Clearb3f78e5e31d3
diff --git a/clearcam.py b/clearcam.py
index cb4e74a..592cb77 100644
--- a/clearcam.py
+++ b/clearcam.py
@@ -397,7 +397,7 @@ class VideoCapture:
raw_bytes = self.proc[cam_name].stdout.read(frame_size)
if len(raw_bytes) != frame_size:
time.sleep(0.5)
- if time.time() - self.start_time[cam_name] > 60: # 1 min grace before restart
+ if time.time() - self.start_time[cam_name] > 15: # 15 sec grace before restart
fail_count += 1
if fail_count > 5:
print(f"{cam_name} FFmpeg frame read failed (count={fail_count}), restarting stream...{self.src[cam_name]}")
@@ -409,7 +409,7 @@ class VideoCapture:
self.frame_num[cam_name] += 1
time.sleep(1 / 100)
except Exception as e:
- print("Waiting for frames from",cam_name)
+ print(f"Waiting for frames from {cam_name}...")
time.sleep(1)
def process_frame(self, cam_name):
diff --git a/utils/helpers.py b/utils/helpers.py
index a999afc..d47e44e 100644
--- a/utils/helpers.py
+++ b/utils/helpers.py
@@ -175,7 +175,6 @@ def export_clip(stream_dir, output_path: Path, live=False, length=5, end=0, star
if combined_path.exists(): combined_path.unlink()
def export_and_upload(cam_name, thumbnail, userID, key, start=None, end=0, length=20, wait=False):
- if wait: time.sleep(10) # todo, objects can be too far ahead
os.makedirs(BASE_DIR / "cameras" / cam_name / "event_clips", exist_ok=True)
mp4_filename = BASE_DIR / "cameras" / f"{cam_name}/event_clips/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.mp4"
temp_output = BASE_DIR / "cameras" / f"{cam_name}/event_clips/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}_temp.mp4"