MATLAB: VideoReader construction is very slow due to frames counting

videoreader performence construction populateframenum

Hello,
I've been using VideoReader to read movie files. I've found out that the construction of a VideoReader is very slow if the movie has a big number of frames.
I've looked into the code, and it seems that the the populateFrameNum method (which called on initiation) scans the entire video, to generate the value of the NumberOfFrames property. And in case the movie has hundreds of thousands of frames, this takes a lot of time to complete.
Is there a way to have the VideoReader extract/calculate the number of frames of a video in a more efficient way ?
(I'm using MATLAB 2014a, on Ubuntu 14.04) Thanks a lot, Eyal.

Best Answer

Generally speaking, No, because of Variable Frame Rate movies.
If you are currently using the read() method, switch to the readFrame() method and do not query the number of frames.
Related Question