Skip to content

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

Scrub (#126)

Rory Clear76d917e183ef
diff --git a/clearcam.py b/clearcam.py
index c59998b..ccf0c23 100644
--- a/clearcam.py
+++ b/clearcam.py
@@ -275,16 +275,21 @@ class VideoCapture:
if self.vod:
command = [
ffmpeg_path,
- "-i", self.src, # No -re for files
- "-c", "copy", # Stream copy for efficiency
+ "-rtsp_transport", "tcp",
+ "-use_wallclock_as_timestamps", "1",
+ "-fflags", "+genpts+discardcorrupt",
+ "-i", self.src,
+ "-c:v", "copy",
+ "-an",
"-f", "hls",
- "-hls_time", "2", # Segment duration
- "-hls_list_size", "0",
- "-hls_flags", "append_list+temp_file",
- "-hls_playlist_type", "event",
- "-an", # No audio
- "-hls_segment_filename", str(path / "stream_%06d.ts"),
- str(path / "stream.m3u8")
+ "-hls_time", "2",
+ "-hls_list_size", "1800",
+ "-hls_flags",
+ "delete_segments+append_list+program_date_time+independent_segments",
+ "-hls_segment_type", "fmp4",
+ "-hls_fmp4_init_filename", "init.mp4",
+ "-hls_segment_filename", str(path / "seg_%06d.m4s"),
+ str(path / "stream.m3u8"),
]
self.hls_proc = subprocess.Popen(command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
self.proc = None
@@ -294,13 +299,16 @@ class VideoCapture:
command = [
ffmpeg_path,
*(["-rtsp_transport", "tcp"] if is_rtsp else []),
+ "-fflags", "+genpts",
+ "-avoid_negative_ts", "make_zero",
"-i", self.src,
"-c", "copy",
+ "-an",
"-f", "hls",
+ "-hls_time", "2",
"-hls_list_size", "0",
- "-hls_flags", "append_list+temp_file",
"-hls_playlist_type", "event",
- "-an",
+ "-hls_flags", "append_list+independent_segments+temp_file",
"-hls_segment_filename", str(path / "stream_%06d.ts"),
str(path / "stream.m3u8")
]
@@ -1625,7 +1633,7 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
if not camera_dirs: return
largest_cam_raw = max(camera_dirs, key=lambda x: x[1])[0]
- largest_cam_det = largest_cam.with_stem(largest_cam.stem + "_det")
+ largest_cam_det = largest_cam_raw.with_stem(largest_cam_raw.stem + "_det")
for largest_cam in [largest_cam_raw, largest_cam_det]:
streams_dir = largest_cam / "streams"
if not streams_dir.exists():