Browse Source

allow setting custom output params and setting the log level for ffmpeg

blakeblackshear 5 năm trước cách đây
mục cha
commit
ba71927d53
2 tập tin đã thay đổi với 20 bổ sung5 xóa
  1. 11 0
      config/config.yml
  2. 9 5
      frigate/video.py

+ 11 - 0
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

+ 9 - 5
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))