reading and displaying video file frame by frame

matlab, video

Solution

Note: `mmreader` API has been discontinued by MATLAB so prefer using `VideoReader`.

See comment by @Vivek.

I usually do this:

obj=mmreader('c:\vid\Akiyo.mp4');
nFrames=obj.NumberOfFrames;
for k=1:nFrames
    img=read(obj,k);
    figure(1),imshow(img,[]);
end

As far as your code is concerned, I saw MATLAB's documentation. You should do the things in following order:

mov=VideoReader('c:\vid\Akiyo.mp4');
vidFrames=read(mov);
nFrames=mov.NumberOfFrames;
for i=1:nFrames
   imshow(vidFrames(:,:,i),[]);  %frames are grayscale
end

Problem

I am newly working with Matlab. I want to read a video file and do some calculations every frame and display every frame. I wrote the following code but every time it only displays the first frame. can anybody please help. ``` mov=VideoReader('c:\vid\Akiyo.mp4'); nFrames=mov.NumberOfFrames; for i=1:nFrames videoFrame=read(mov,i); imshow(videoFrame); end ```

Original source