MATLAB: Can’t get video’s number of frames before processing

Computer Vision Toolboxnumber of framesvideoreadervision.videofilereader

I used videoReader–> read but i get "[]" in the number of frames field. i have tried using vision.VideoFileReader but it gives a less informative header ( without that kind of information)
I need the frame number BEFORE processing , not after. I am uploading the video so you could try yourselves

Best Answer

Hi Lirian,
The vision.VideoFileReader system object allows reading only one frame at a time and does not allow random access.
I tried to open this file using Windows Media Player but was unable to do so. I believe I need some additional codecs as you mentioned.
Can you try to force VideoReader to read the last frame as below
if true
vidObj = VideoReader('swipeCut.mp4');
read(vidObj, Inf);
vidObj.NumberOfFrames
end
This should display the last frame read. However, this operation might take time depending upon the size of the video.
I am curious however as to why you need the total number of frames?
Hope this helps.
Dinesh
Related Question