Green Noob
Green Noob

Reputation: 408

Why is MATLAB unable to determine the number of frames in a video file?

I am trying to reproduce these results obtained by researchers from MIT. The code is available here.

These are the warnings that I get when run the script:

In reproduceResults at 17

Processing .\data\baby.mp4

Warning: Unable to determine the number of frames in this file.

Processing .\data\baby2.mp4

Error using VideoReader/init (line 436)

I tried to open a file using VideoReader directly and this is the warning that I get:

>> videoObj = VideoReader('baby.mp4'); 
Warning: Unable to determine the number of frames in this file.

I followed the advice from the MathWorks forum tried the get() function. This is the output:

>> get(videoObj)
  General Settings:
    Duration = 10.0333
    Name = baby.mp4
    Path = C:\Documents and Settings\Administrator\Desktop\EVM_Matlab-1.1\EVM_Matlab\data
    Tag = 
    Type = VideoReader
    UserData = []

  Video Settings:
    BitsPerPixel = 24
    FrameRate = 30.0000
    Height = 544
    NumberOfFrames = []
    VideoFormat = RGB24
    Width = 960

I am running MATLAB R2013a on Windows XP.

Upvotes: 0

Views: 2489

Answers (1)

Dinesh Iyer
Dinesh Iyer

Reputation: 691

The VideoReader has to scan the entire file to determine the number of frames that are present in the file for certain file formats. The reason it has to do this is because of a class of files that have variable frame rate.

Typically, the frame-counting occurs during construction. However, for some files, it returns an empty.

To force, VideoReader to count the number of frames, read the last frame using

data = read(vidObj, Inf);
numFrames = vidObj.NumberOfFrames;

Hope this helps.

Dinesh

Upvotes: 6

Related Questions