MATLAB Answers

Akhil krishnan
0

how to convert video in to image frames using matlab?

Asked by Akhil krishnan
on 7 Jan 2013
Latest activity Answered by Image Analyst
on 17 Mar 2016

how to convert video in to image frames using matlab?

  0 Comments

2 Answers

Answer by Lalit Patil on 7 Jan 2013

 vid=mmreader('video.avi');
 numFrames = vid.NumberOfFrames;
 n=numFrames;
 for i = 1:2:n
 frames = read(vid,i);
 imwrite(frames,['Image' int2str(i), '.jpg']);
 im(i)=image(frames);
 end

  1 Comment

Hi. Suppose I need a single frame from each second of a video, how can I modify this code for the same?


Answer by Image Analyst
on 17 Mar 2016

Namith:

You can use the VideoReader class to set the starting time of the video, then use read() to extract a frame from the video at exactly that time. Then use imwrite() to save it to disk. Attached is a demo that does something similar (but not exactly what you want). The demo writes out every single frame to files. You just need to set the time with the method for doing that before you extract the frame.

  0 Comments


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!