I have simplified a code I have written, please have a look at it below.
video = VideoReader('IMG_6174.MOV');
video = false;
if video ~= false
totalFrames = video.duration * video.framerate;
vidStruct = struct('cdata', zeros(300, 300, 3, 'uint8'), 'colormap', );
for frameNumber = 1:totalFrames
vidStruct(frameNumber).cdata = readFrame(vidObj);
disp(strcat('Frame missed. Number:', int2str(frameNumber)));
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
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.