VideoReader reads .MOV file correctly but cannot read individual frames in MATLAB

11 visualizaciones (últimos 30 días)
I have simplified a code I have written, please have a look at it below.
try
video = VideoReader('IMG_6174.MOV');
catch
video = false;
end
if video ~= false
totalFrames = video.duration * video.framerate;
end
vidStruct = struct('cdata', zeros(300, 300, 3, 'uint8'), 'colormap', []);
for frameNumber = 1:totalFrames
try
vidStruct(frameNumber).cdata = readFrame(vidObj);
catch
disp(strcat('Frame missed. Number:', int2str(frameNumber)));
end
end
What I am trying to do is simple. I just want to read a video file and if I am able to read it I want to put each frame of that video file into a struct. If there is an error in one of the frames it will display an error message as you can see in the code.
That code above gives me this output: (I have shortened it to preserve space but it is the same message for all of the frames)
Frame missed. Number:1
Frame missed. Number:2
Frame missed. Number:3
.
.
.
Frame missed. Number:71
Frame missed. Number:72
Frame missed. Number:73
Furthermore, a while loop version with
while hasFrame(video)
....
end
also does not work because hasFrame returns 0. I have checked the data of the video variable and it matching with the info from the actual video file. I am using MATLAB r2015b. Also, the works OK with VLC Media Player.
Any help is appreciated. Thank you very much.

Respuestas (0)

Etiquetas

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by