mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
use ffprobe to get frame shape (fixes #87)
This commit is contained in:
parent
af247275cf
commit
6263912655
@ -11,6 +11,7 @@ import numpy as np
|
|||||||
import prctl
|
import prctl
|
||||||
import copy
|
import copy
|
||||||
import itertools
|
import itertools
|
||||||
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from frigate.util import tonumpyarray, LABELS, draw_box_with_label, calculate_region, EventsPerSecond
|
from frigate.util import tonumpyarray, LABELS, draw_box_with_label, calculate_region, EventsPerSecond
|
||||||
from frigate.object_detection import RegionPrepper, RegionRequester
|
from frigate.object_detection import RegionPrepper, RegionRequester
|
||||||
@ -42,13 +43,26 @@ class FrameTracker(threading.Thread):
|
|||||||
del self.recent_frames[k]
|
del self.recent_frames[k]
|
||||||
|
|
||||||
def get_frame_shape(source):
|
def get_frame_shape(source):
|
||||||
# capture a single frame and check the frame shape so the correct array
|
ffprobe_cmd = " ".join([
|
||||||
# size can be allocated in memory
|
'ffprobe',
|
||||||
video = cv2.VideoCapture(source)
|
'-v',
|
||||||
ret, frame = video.read()
|
'panic',
|
||||||
frame_shape = frame.shape
|
'-show_error',
|
||||||
video.release()
|
'-show_streams',
|
||||||
return frame_shape
|
'-of',
|
||||||
|
'json',
|
||||||
|
'"'+source+'"'
|
||||||
|
])
|
||||||
|
print(ffprobe_cmd)
|
||||||
|
p = sp.Popen(ffprobe_cmd, stdout=sp.PIPE, shell=True)
|
||||||
|
(output, err) = p.communicate()
|
||||||
|
p_status = p.wait()
|
||||||
|
info = json.loads(output)
|
||||||
|
print(info)
|
||||||
|
|
||||||
|
video_info = [s for s in info['streams'] if s['codec_type'] == 'video'][0]
|
||||||
|
|
||||||
|
return (video_info['height'], video_info['width'], 3)
|
||||||
|
|
||||||
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_')}
|
||||||
|
Loading…
Reference in New Issue
Block a user