handle case where video is so black we fail to get a thumbnail
This commit is contained in:
2
TODO
2
TODO
@@ -35,8 +35,6 @@
|
||||
|
||||
* support animated gifs in html5 canvas
|
||||
|
||||
* if a video is really mostly black, then we dont get a thumbnail... (see: 20210526_205257_01.mp4)
|
||||
|
||||
## DB
|
||||
* Dir can have date in the DB, so we can do Oldest/Newest dirs in Folder view
|
||||
|
||||
|
||||
@@ -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