I am learning Python and I can’t figure out how to download a 5 MB video and transfer it to a list of images, I have 2 GB of RAM.
Here is my code:
# преобразуем видео в список изображений def video_to_array(path): cap = cv2.VideoCapture(path) im_data = [] while(cap.isOpened()): ret, frame = cap.read() if ret == True: im_data.append(frame) else: break cap.release() cv2.destroyAllWindows() return im_data # вызываем функцию Arr=video_to_array('test.mp4') I suppose it's about im_data.append(frame) . I tried to set the size of the array before the start of the cycle [[width,height,3]]*frames , but the result was the same. Also tried using the numpy np.array(frames,width,height,3)
What am I doing wrong? Maybe he should take such a volume? Or is it still possible to form an array of images I do not use such a decent amount of OP?
Binding to opencv is optional. Perhaps someone will tell the library that solves my problem. Thank!