VideoReader construction is very slow due to frames counting

4 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 9 May 2016
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.
  2 Comments
Eyal Itskovits
Eyal Itskovits on 10 May 2016
Thanks a lot for the response.
I didn't quite figure out why should I move to readFrame.
Walter Roberson
Walter Roberson on 10 May 2016
The read() method is being removed, replaced by readFrame() . The underlying code for read() is tied up with the scanning being done for the number of frames, but the underlying code for readFrame() never tries to calculate the number of frames (it just keeps track of the maximum frame number it has encountered so far.)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!