From 69406343eedc7ca20dce4bd30efc7d32cefe66d2 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 13 Sep 2020 07:46:38 -0500 Subject: [PATCH] allow setting the camera fps if needed --- config/config.example.yml | 8 ++++++++ detect_objects.py | 2 ++ frigate/edgetpu.py | 2 ++ process_clip.py | 5 +++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 33e7af0bb..b317abe34 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -131,6 +131,14 @@ cameras: # height: 1280 # width: 720 + ################ + ## Specify the framerate of your camera + ## + ## NOTE: This should only be set in the event ffmpeg is unable to determine your camera's framerate + ## on its own and the reported framerate for your camera in frigate is well over what is expected. + ################ + # fps: 5 + ################ ## Optional mask. Must be the same aspect ratio as your video feed. Value is either the ## name of a file in the config directory or a base64 encoded bmp image prefixed with diff --git a/detect_objects.py b/detect_objects.py index 82ad5f3c9..6d07cdd7e 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -203,6 +203,8 @@ def main(): ffmpeg_hwaccel_args = ffmpeg.get('hwaccel_args', FFMPEG_DEFAULT_CONFIG['hwaccel_args']) ffmpeg_input_args = ffmpeg.get('input_args', FFMPEG_DEFAULT_CONFIG['input_args']) ffmpeg_output_args = ffmpeg.get('output_args', FFMPEG_DEFAULT_CONFIG['output_args']) + if not config.get('fps') is None: + ffmpeg_output_args = ["-r", str(config.get('fps'))] + ffmpeg_output_args if config.get('save_clips', {}).get('enabled', False): ffmpeg_output_args = [ "-f", diff --git a/frigate/edgetpu.py b/frigate/edgetpu.py index 336746444..0fd7b4323 100644 --- a/frigate/edgetpu.py +++ b/frigate/edgetpu.py @@ -35,6 +35,7 @@ class ObjectDetector(ABC): class LocalObjectDetector(ObjectDetector): def __init__(self, tf_device=None, labels=None): + self.fps = EventsPerSecond() if labels is None: self.labels = {} else: @@ -83,6 +84,7 @@ class LocalObjectDetector(ObjectDetector): float(d[1]), (d[2], d[3], d[4], d[5]) )) + self.fps.update() return detections def detect_raw(self, tensor_input): diff --git a/process_clip.py b/process_clip.py index c46e88dbb..f754e4687 100644 --- a/process_clip.py +++ b/process_clip.py @@ -42,12 +42,13 @@ class ProcessClip(): object_detector = LocalObjectDetector(labels='/labelmap.txt') object_tracker = ObjectTracker(10) - process_fps = EventsPerSecond() + process_fps = mp.Value('d', 0.0) + detection_fps = mp.Value('d', 0.0) current_frame = mp.Value('d', 0.0) stop_event = mp.Event() process_frames(self.camera_name, self.frame_queue, self.frame_shape, self.frame_manager, motion_detector, object_detector, object_tracker, self.detected_objects_queue, - process_fps, current_frame, objects_to_track, object_filters, mask, stop_event, exit_on_empty=True) + process_fps, detection_fps, current_frame, objects_to_track, object_filters, mask, stop_event, exit_on_empty=True) def objects_found(self, debug_path=None): obj_detected = False