mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
fallback to opencv to detect resolution and allow config to specify
This commit is contained in:
parent
6263912655
commit
cd057370e1
@ -82,6 +82,12 @@ cameras:
|
|||||||
# input_args: []
|
# input_args: []
|
||||||
# output_args: []
|
# output_args: []
|
||||||
|
|
||||||
|
################
|
||||||
|
## Optionally specify the resolution of the video feed. Frigate will try to auto detect if not specified
|
||||||
|
################
|
||||||
|
# height: 1280
|
||||||
|
# width: 720
|
||||||
|
|
||||||
################
|
################
|
||||||
## Optional mask. Must be the same dimensions as your video feed.
|
## Optional mask. Must be the same dimensions as your video feed.
|
||||||
## The mask works by looking at the bottom center of the bounding box for the detected
|
## The mask works by looking at the bottom center of the bounding box for the detected
|
||||||
|
@ -62,8 +62,16 @@ def get_frame_shape(source):
|
|||||||
|
|
||||||
video_info = [s for s in info['streams'] if s['codec_type'] == 'video'][0]
|
video_info = [s for s in info['streams'] if s['codec_type'] == 'video'][0]
|
||||||
|
|
||||||
|
if video_info['height'] != 0 and video_info['width'] != 0:
|
||||||
return (video_info['height'], video_info['width'], 3)
|
return (video_info['height'], video_info['width'], 3)
|
||||||
|
|
||||||
|
# fallback to using opencv if ffprobe didnt succeed
|
||||||
|
video = cv2.VideoCapture(source)
|
||||||
|
ret, frame = video.read()
|
||||||
|
frame_shape = frame.shape
|
||||||
|
video.release()
|
||||||
|
return frame_shape
|
||||||
|
|
||||||
def get_ffmpeg_input(ffmpeg_input):
|
def get_ffmpeg_input(ffmpeg_input):
|
||||||
frigate_vars = {k: v for k, v in os.environ.items() if k.startswith('FRIGATE_')}
|
frigate_vars = {k: v for k, v in os.environ.items() if k.startswith('FRIGATE_')}
|
||||||
return ffmpeg_input.format(**frigate_vars)
|
return ffmpeg_input.format(**frigate_vars)
|
||||||
@ -170,6 +178,9 @@ class Camera:
|
|||||||
'show_timestamp': self.config.get('snapshots', {}).get('show_timestamp', True)
|
'show_timestamp': self.config.get('snapshots', {}).get('show_timestamp', True)
|
||||||
}
|
}
|
||||||
self.regions = self.config['regions']
|
self.regions = self.config['regions']
|
||||||
|
if 'width' in self.config and 'height' in self.config:
|
||||||
|
self.frame_shape = (self.config['height'], self.config['width'], 3)
|
||||||
|
else:
|
||||||
self.frame_shape = get_frame_shape(self.ffmpeg_input)
|
self.frame_shape = get_frame_shape(self.ffmpeg_input)
|
||||||
self.frame_size = self.frame_shape[0] * self.frame_shape[1] * self.frame_shape[2]
|
self.frame_size = self.frame_shape[0] * self.frame_shape[1] * self.frame_shape[2]
|
||||||
self.mqtt_client = mqtt_client
|
self.mqtt_client = mqtt_client
|
||||||
|
Loading…
Reference in New Issue
Block a user