Read frames from the mp4 file

1 visualización (últimos 30 días)
niranjan v
niranjan v el 18 de Oct. de 2019
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');

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by