Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for .mp4 format? #9

Closed
ramnamaqsood776 opened this issue Aug 2, 2019 · 2 comments
Closed

Not working for .mp4 format? #9

ramnamaqsood776 opened this issue Aug 2, 2019 · 2 comments

Comments

@ramnamaqsood776
Copy link

Hello
Can you please guide me that why this code is not running for .mp4 format?
Thank you

@okankop
Copy link
Owner

okankop commented Aug 2, 2019

You need to give image frames in numpy or PIL fotmat. So you need to extract frames form video of format .mp4 first.

@PHDPeter
Copy link

PHDPeter commented Sep 10, 2020

import cv2
def load_video(video_path):
# 'video' should be either a list of images from type of numpy array or PIL images
cap = cv2.VideoCapture(video_path)
ret, frame = cap.read()
frame_list=[]
while ret == True:
ret, frame = cap.read()
frame_list.append(frame)

#cap.release()
print(len(frame_list))
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)  # float
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)  # float

cap.release()
return frame_list, width,height

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants