Skip to content

Commit

Permalink
allow setting custom output params and setting the log level for ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed Aug 25, 2019
1 parent 04fed31 commit ba71927
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 11 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions frigate/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self, name, config, prepped_frame_queue, mqtt_client, mqtt_prefix):
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',
Expand All @@ -133,6 +134,10 @@ def __init__(self, name, config, prepped_frame_queue, mqtt_client, mqtt_prefix):
'-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]
Expand Down Expand Up @@ -231,17 +236,16 @@ def start_or_restart_capture(self):

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))

Expand Down

0 comments on commit ba71927

Please sign in to comment.