Skip to content

Commit

Permalink
Update pyfunc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vasusen-code authored May 19, 2023
1 parent bff3e4f commit ede0826
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion ethon/pyfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ))
Expand All @@ -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

0 comments on commit ede0826

Please sign in to comment.