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!