diff --git a/TODO b/TODO index 2c61e84..d33be7a 100644 --- a/TODO +++ b/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 diff --git a/pa_job_manager.py b/pa_job_manager.py index 9f606c1..88bc064 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -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: