Extract frames from a mp4 video and saving in a file
이전 댓글 표시
I want to Extract frames from a video and save them in a file. This is the code I used:
clc;
close all;
workspace;
video = 'test.mp4';
vid = VideoReader(video);
opFolder = fullfile(cd,'Frames');
if ~exist(opFolder,'dir')
mkdir(opFolder);
end
numFrames = vid.CurrentTime;
numFramesWritten = 0;
for t=1:numFrames
currFrame = read(mov,t);
opBaseFileName = sprintf('%3.3d.png', t);
opFullFileName = fullfile(opFolder, opBaseFileName);
imwrite(currFrame, opFullFileName, 'png');
progIndication = sprintf('Wrote frame %4d of %d.', t, numFrames);
fprintf(progIndication);
numFramesWritten = numFramesWritten + 1;
end
progIndication = sprintf('Wrote %d frames to folder "%s"',numFramesWritten, opFolder);
fprintf(progIndication);
댓글 수: 3
Geoff Hayes
2018년 3월 16일
Nabeel - what is your question? Does your code do what you expect or not? Or are you just posting some code for others to see. Please clarify.
Nabeel Ahmed
2018년 3월 16일
Nabeel Ahmed
2018년 3월 16일
답변 (1개)
Anay Aggarwal
2022년 7월 12일
0 개 추천
Hi Nabeel
I have an understanding that you want to extract frames from an mp4 video.
Please check out the following link to get the reference:
Regards
카테고리
도움말 센터 및 File Exchange에서 Video Formats and Interfaces에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!