How to extract frames from a video in MATLAB?
12 views (last 30 days)
Hi, I have managed to read the video frames, but how do i extract them?
videoFReader = vision.VideoFileReader('face.avi');
videoPlayer = vision.VideoPlayer;
videoFrame = step(videoFReader);
Any help would be appreciated
Image Analyst on 2 Mar 2014
And what is the difference between a "video frame", and a "screen shot"? Please upload an image of each one so we can tell the difference. Do you mean like you want the task bar, parts of MATLAB, the figure toolbar, and any other programs that might happen to be running on your program, as well as parts of your desktop to be captured and saved?
More Answers (1)
cp sahu on 30 Apr 2015
Edited: cp sahu on 30 Apr 2015
%this code can run on newer versions of Matlab for older versions use %mmreader instead of VideoReader
%pass the path of the video file with extension
for k = 1 : 40
%fill in the no of frames the video contains or anything less than that, The
%no of frames in a video can be identified by reading info about the video.
%i.e. the frame rate in fps, multiply it with video length in sec.
this_frame = read(video, k);
a=sprintf('Frame #%d.jpg', k); % store the name of the frame in 'a'.
imwrite(this_frame,a,'jpg'); % store the extracted frame under the compression scheme with third parameter.