소스 검색

cleanup dynamic mp4 clips

Blake Blackshear 3 년 전
부모
커밋
9cab5da74c
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      frigate/record.py

+ 9 - 0
frigate/record.py

@@ -140,6 +140,14 @@ class RecordingCleanup(threading.Thread):
         self.config = config
         self.stop_event = stop_event
 
+    def clean_tmp_clips(self):
+        # delete any clips more than 5 minutes old
+        for p in Path("/tmp/cache").rglob("clip_*.mp4"):
+            logger.debug(f"Checking tmp clip {p}.")
+            if p.stat().st_mtime < (datetime.datetime.now().timestamp() - 60 * 1):
+                logger.debug("Deleting tmp clip.")
+                p.unlink(missing_ok=True)
+
     def expire_recordings(self):
         logger.debug("Start expire recordings (new).")
 
@@ -262,6 +270,7 @@ class RecordingCleanup(threading.Thread):
                 break
 
             self.expire_recordings()
+            self.clean_tmp_clips()
 
             if counter == 0:
                 self.expire_files()