Compare commits

..

4 Commits

Author SHA1 Message Date
kluszczyn
2bc8736fd9 Recordings - fix expire_file 2020-12-22 09:58:26 -05:00
Blake Blackshear
e9b3b09cc2 add clips endpoint to readme 2020-12-22 09:58:26 -05:00
Blake Blackshear
ca337c32b4 better mask error handling 2020-12-22 09:58:26 -05:00
Blake Blackshear
24b8bd7c85 fix tmpfs 2020-12-22 09:58:26 -05:00
4 changed files with 19 additions and 11 deletions

View File

@@ -871,6 +871,9 @@ Returns data for a single event.
### `/events/<id>/snapshot.jpg`
Returns a snapshot for the event id optimized for notifications. Works while the event is in progress and after completion. Passing `?format=android` will convert the thumbnail to 2:1 aspect ratio.
### `/clips/<camera>-<id>.mp4`
Video clip for the given camera and event id.
[Back to top](#documentation)
## MQTT Topics

View File

@@ -38,19 +38,19 @@ class FrigateApp():
self.camera_metrics = {}
def ensure_dirs(self):
tmpfs_size = self.config.save_clips.tmpfs_cache_size
if tmpfs_size:
logger.info(f"Creating tmpfs of size {tmpfs_size}")
rc = os.system(f"mount -t tmpfs -o size={tmpfs_size} tmpfs {CACHE_DIR}")
if rc != 0:
logger.error(f"Failed to create tmpfs, error code: {rc}")
for d in [RECORD_DIR, CLIPS_DIR, CACHE_DIR]:
if not os.path.exists(d) and not os.path.islink(d):
logger.info(f"Creating directory: {d}")
os.makedirs(d)
else:
logger.debug(f"Skipping directory: {d}")
tmpfs_size = self.config.save_clips.tmpfs_cache_size
if tmpfs_size:
logger.info(f"Creating tmpfs of size {tmpfs_size}")
rc = os.system(f"mount -t tmpfs -o size={tmpfs_size} tmpfs {CACHE_DIR}")
if rc != 0:
logger.error(f"Failed to create tmpfs, error code: {rc}")
def init_logger(self):
self.log_process = mp.Process(target=log_process, args=(self.log_queue,), name='log_process')

View File

@@ -1,5 +1,6 @@
import base64
import json
import logging
import os
from typing import Dict
@@ -11,6 +12,8 @@ import yaml
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
logger = logging.getLogger(__name__)
DETECTORS_SCHEMA = vol.Schema(
{
vol.Required(str): {
@@ -743,7 +746,9 @@ class CameraConfig():
cv2.fillPoly(mask_img, pts=[contour], color=(0))
else:
mask_file = cv2.imread(f"/config/{mask}", cv2.IMREAD_GRAYSCALE)
if not mask_file.size == 0:
if mask_file is None or mask_file.size == 0:
logger.warning(f"Could not read mask file {mask}")
else:
mask_img[np.where(mask_file==[0])] = [0]
def _get_ffmpeg_cmd(self, ffmpeg_input):

View File

@@ -98,9 +98,9 @@ class RecordingMaintainer(threading.Thread):
delete_before[name] = datetime.datetime.now().timestamp() - SECONDS_IN_DAY*camera.record.retain_days
for p in Path('/media/frigate/recordings').rglob("*.mp4"):
if not p.parent in delete_before:
if not p.parent.name in delete_before:
continue
if p.stat().st_mtime < delete_before[p.parent]:
if p.stat().st_mtime < delete_before[p.parent.name]:
p.unlink(missing_ok=True)
def run(self):
@@ -122,4 +122,4 @@ class RecordingMaintainer(threading.Thread):
self.move_files()