handle case where video is so black we fail to get a thumbnail
This commit is contained in:
@@ -1418,9 +1418,19 @@ def GenVideoThumbnail(job, file):
|
||||
try:
|
||||
vcap = cv2.VideoCapture(file)
|
||||
res, frame = vcap.read()
|
||||
first_res = res
|
||||
first_frame = frame
|
||||
frame_cnt=0
|
||||
# if the mean pixel value is > 15, we have something worth making a sshot of (no black frame at start being the sshot)
|
||||
while frame.mean() < 15 and res:
|
||||
# limit it to 1000 frames jic
|
||||
while res and frame.mean() < 15 and frame_cnt < 1000:
|
||||
res, frame = vcap.read()
|
||||
frame_cnt += 1
|
||||
# if we never got a frame that is not dark, then use first frame
|
||||
if not res:
|
||||
res = first_res
|
||||
frame = first_frame
|
||||
|
||||
w = vcap.get(cv2.cv2.CAP_PROP_FRAME_WIDTH)
|
||||
h = vcap.get(cv2.cv2.CAP_PROP_FRAME_HEIGHT)
|
||||
if w > h:
|
||||
|
||||
Reference in New Issue
Block a user