Handling large AVI videos

Im using MATLAB R2010b with Core2Duo 2.1GHz & 3 GB RAM. I need to analyse AVI videos frame-by-frame. Im using AVIREAD but it let's me read videos only upto 15 sec or 2-3 MB. How can I read larger videos into Frames ?

Answers (2)

You say you need to analyze the video "frame-by-frame". That seems to indicate that you don't need to store all of the frames in memory at once. You can just do the processing one frame at a time and clear it as you move on to the next frame.
You can use aviread but I would recommend using VideoReader instead:
vid = VideoReader('video.avi');
for iFrame = 1:vid.NumberOfFrames
frame = read(vid, iFrame);
%
% analyze the frame
%
end
Walter Roberson
Walter Roberson on 6 Apr 2011

0 votes

2 - 3 Mb ? Ummm, how big are your frames and what frame rate are you using? I estimate 15 seconds at being roughly 400 megabyte at 24 frames per second of 768 x 512 with 3 bytes per pixel.

5 Comments

Im using 640x480 avi files..... Does it hav anything to do with Compression ? Those 15 second avi files are 2-3 MB is size...... If i try 20 seconds then AVIREAD gives 'out of memory' error
What frame rates are the files? 20 seconds of 640 x 480 at 24 frames per second would exceed 400 megabytes.
Compression can have great deal to do with the size, especially if large portions of the background are static.
Are you using the 32 bit version of Matlab for Windows? If so then at the point where you would do the reading of the file, insert a call to memory() http://www.mathworks.com/help/techdoc/ref/memory.html to find out how much free memory you have available.
Im using 32bit Matlab. memory() shows
Maximum possible array: 714 MB (7.484e+008 bytes) *
Memory available for all arrays: 1105 MB (1.159e+009 bytes) **
Memory used by MATLAB: 617 MB (6.471e+008 bytes)
Physical Memory (RAM): 3002 MB (3.148e+009 bytes)
What does aviinfo() return for the file?
Also, to cross-check, did you invoke memory() at the command prompt, or did you put the call in right at the place the file would be read? To me the values look like what would be returned at the command prompt (unless your program did almost nothing before trying to read the file.)

Sign in to comment.

Asked:

on 6 Apr 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!