Python Forum
memory issue loading movie to numpy array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
memory issue loading movie to numpy array
#1
I have a movie, .mts file, that I want to be able to read into a numpy array that is (w,h,3,f), where w is the frame's width, h its height, and f the number of frames in the movie. 3 refers to the RGB value. Below is my program for doing it. My problem though is that when I run it that it consumes all of the memory on my computer and everything freezes up. I don't understand why since the movie is only 26 MB and I have 3.7GB of RAM memory . I am using Spyder and when not running it says memory is 36% in the lower right hand corner and then jumps up to 96% memory when the program is running and freezes. Why is this happening and how do I fix this? Is there a better way to write this?

import cv2
    
cap2 = cv2.VideoCapture('//home//jr//Desktop//Movie1.MTS')
movieA=[]
while(cap2.isOpened()):
    status, frame = cap2.read()
    if status==True:
        movieA.append(frame)
    else:
        break
cap2.release()
Reply
#2
The video file is encoded and shrinked in size, if you want an array of the data
it needs to be decoded and that means the amount is increasing dramatically.
https://www.wowza.com/blog/video-codecs-encoding
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 289 Mar-26-2024, 02:18 PM
Last Post: snippsat
Video Movie Recommender oslagosboi 3 2,939 Feb-21-2023, 08:23 AM
Last Post: JhonSteve
  reshaping 2D numpy array paul18fr 3 970 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,528 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Numpy array BrianPA 13 4,837 Jan-23-2021, 09:36 AM
Last Post: Serafim
  How to fill datetime64 field in numpy structured array? AlekseyPython 0 2,234 Oct-20-2020, 08:17 AM
Last Post: AlekseyPython
  Adding data in 3D array from 2D numpy array asmasattar 0 2,169 Jul-23-2020, 10:55 AM
Last Post: asmasattar
  JSON file Loading issue punna111 4 8,488 Jun-29-2020, 08:07 AM
Last Post: buran
  converting dataframe to int numpy array glennford49 1 2,290 Apr-04-2020, 06:15 AM
Last Post: snippsat
  Replacing sub array in Numpy array ThemePark 5 4,087 Apr-01-2020, 01:16 PM
Last Post: ThemePark

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020