From ba71927d53050fbca582e18dc92424c483c7fff3 Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Wed, 21 Aug 2019 20:15:49 -0500 Subject: [PATCH] allow setting custom output params and setting the log level for ffmpeg --- config/config.yml | 11 +++++++++++ frigate/video.py | 14 +++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/config/config.yml b/config/config.yml index ab96ca1ad..86e95b960 100644 --- a/config/config.yml +++ b/config/config.yml @@ -47,11 +47,22 @@ cameras: # - -hwaccel_output_format # - yuv420p + ################ + # FFmpeg log level. Default is "panic". https://ffmpeg.org/ffmpeg.html#Generic-options + ################ + # ffmpeg_log_level: panic + ################ # Optional custom input args. Some cameras may need custom ffmpeg params to work reliably. Specifying # these will replace the default input params. ################ # ffmpeg_input_args: [] + + ################ + # Optional custom output args. Some cameras may need custom ffmpeg params to work reliably. Specifying + # these will replace the default output params. + ################ + # ffmpeg_output_args: [] regions: - size: 350 diff --git a/frigate/video.py b/frigate/video.py index 5c4093958..c4891edcf 100644 --- a/frigate/video.py +++ b/frigate/video.py @@ -121,6 +121,7 @@ class Camera: self.recent_frames = {} self.rtsp_url = get_rtsp_url(self.config['rtsp']) self.take_frame = self.config.get('take_frame', 1) + self.ffmpeg_log_level = self.config.get('ffmpeg_log_level', 'panic') self.ffmpeg_hwaccel_args = self.config.get('ffmpeg_hwaccel_args', []) self.ffmpeg_input_args = self.config.get('ffmpeg_input_args', [ '-avoid_negative_ts', 'make_zero', @@ -133,6 +134,10 @@ class Camera: '-stimeout', '5000000', '-use_wallclock_as_timestamps', '1' ]) + self.ffmpeg_output_args = self.config.get('ffmpeg_output_args', [ + '-f', 'rawvideo', + '-pix_fmt', 'rgb24' + ]) self.regions = self.config['regions'] self.frame_shape = get_frame_shape(self.rtsp_url) self.frame_size = self.frame_shape[0] * self.frame_shape[1] * self.frame_shape[2] @@ -231,17 +236,16 @@ class Camera: def start_ffmpeg(self): ffmpeg_global_args = [ - '-hide_banner', '-loglevel', 'panic' + '-hide_banner', '-loglevel', self.ffmpeg_log_level ] ffmpeg_cmd = (['ffmpeg'] + ffmpeg_global_args + self.ffmpeg_hwaccel_args + self.ffmpeg_input_args + - ['-i', self.rtsp_url, - '-f', 'rawvideo', - '-pix_fmt', 'rgb24', - 'pipe:']) + ['-i', self.rtsp_url] + + self.ffmpeg_output_args + + ['pipe:']) print(" ".join(ffmpeg_cmd))