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

This commit is contained in:
blakeblackshear 2019-08-21 20:15:49 -05:00 committed by Blake Blackshear
parent 04fed31eac
commit ba71927d53
2 changed files with 20 additions and 5 deletions

View File

@ -47,12 +47,23 @@ 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
x_offset: 0

View File

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