Extracting video frames from specific index in matlab

When there is not enough memory available for extracting all the video frames in matlab, we often read specific frames by giving the indices instead of reading all of the frames into the memory.

Example

obj = mmreader('abc.avi');
vid = read(obj,[150 300]); % read(obj,[<starting index of frames> <ending index of frames>])
frames = obj.NumberOfFrames;
for x = 1 : frames
    imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.jpeg'));
end
Share

You may also like...