Read frames from the mp4 file
조회 수: 1 (최근 30일)
이전 댓글 표시
filename = '01_original.mp4';
mov = VideoReader(filename);
opFolder = fullfile(cd, 'snaps');
if ~exist(opFolder, 'dir')
mkdir(opFolder);
end
numFrames =mov.NumberOfFrames;
numFramesWritten = 0;
for t = 1 : numFrames
currFrame = read(mov,t); %reading individual frames
opBaseFileName = sprintf('%3.3d.png', t);
opFullFileName = fullfile(opFolder, opBaseFileName);
imwrite(currFrame, opFullFileName, 'png');
progIndication = sprintf('Wrote frame %4d of %d.', t, numFrames);
disp(progIndication);
numFramesWritten = numFramesWritten + 1;
end %end of 'for' loop
progIndication = sprintf('Wrote %d frames to folder "%s"',numFramesWritten, opFolder);
disp(progIndication);
I just want to read frames from the mp4 file and try to storing in a snaps folder which im created.
it works fine for avi file. but when i reading the mp4 file i got the error
Error using imwrite (line 442)
Expected DATA to be nonempty.
Error in frames (line 13)
imwrite(currFrame, opFullFileName, 'png');
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!