I am having trouble using VideoReader to determine the correct number of frames in a video file,
videoObj = VideoReader('test.mp4') ; Warning: Unable to determine the number of frames in this file.
This workaround fails,
lastFrame = read(videoObj, inf)
Error using VideoReader/read (line 86) The frame index requested is beyond the end of the file. The following code returns a different number of frames each time it's run, e.g. 100, 104, 112.
LenSeq = 300; videoObj = VideoReader(test.mp4'); nFrames = xyloObj.NumberOfFrames; vidHeight = xyloObj.Height; vidWidth = xyloObj.Width;
cnt = 1; for k = 1:10:LenSeq, tp_image = rgb2gray( read(xyloObj, k) ); end
If VideoReader skipping or repeating frames on each pass through the file, how can I get the correct number of frames?
In addition, xyloObj.NumberOfFrames have value of . (nothing) Is this cause a problem?
More info: problem is present for both R2011a run on Windows 7 (64-bit versions), video format is MPEG-4/H.264, size of the video is 4,782KB, and it's a variable frame rate file.
No products are associated with this question.
NumberOfFrames would not be meaningfully filled in on a variable frame rate file, instead reflecting only the highest frame that you have read so far.
What if you ask to read the last frame first off, then throw that away and go from the beginning?
After that NumberOfFrames should be meaningful.