diff --git a/ethon/pyfunc.py b/ethon/pyfunc.py index 6e195d1..e2aeb87 100644 --- a/ethon/pyfunc.py +++ b/ethon/pyfunc.py @@ -29,7 +29,7 @@ def bash(cmd): return output, error #to get width, height and duration(in sec) of a video -def video_metadata(file): +def videometadata(file): vcap = cv2.VideoCapture(f'{file}') width = round(vcap.get(cv2.CAP_PROP_FRAME_WIDTH )) height = round(vcap.get(cv2.CAP_PROP_FRAME_HEIGHT )) @@ -38,3 +38,32 @@ def video_metadata(file): duration = round(frame_count / fps) data = {'width' : width, 'height' : height, 'duration' : duration } return data + +def video_metadata(file): + height = 720 + width = 1280 + duration = 0 + try: + height, width, duration = findVideoResolution(file) + if duration == 0: + data = videometadata(file) + duration = data["duration"] + if duration is None: + duration = 0 + except Exception as e: + try: + if 'height' in str(e): + data = videometadata(file) + height = data["height"] + width = data["width"] + duration = duration(file) + if duration == 0: + data = videometadata(file) + duration = data["duration"] + if duration is None: + duration = 0 + except exception as e: + print(e) + height, width, duration = 720, 1280, 0 + data = {'width' : width, 'height' : height, 'duration' : duration } + return data