Matlab: Error using VideoFileReader/setup

2019-07-19 16:07发布

I'm using this code:

h = vision.VideoFileReader('num2.avi')

h = 
System: vision.VideoFileReader
Properties:
             Filename: '/Users/LoFe/Documents/BME/Work/Work/Work/num2.avi'
            PlayCount: Inf                                                
      ImageColorSpace: 'RGB'                                              
  VideoOutputDataType: 'single'  

It is working well, but when I want to call step on it, i get this:

while ~isDone(h)
    hFrame = step(h);
end

Error using VideoFileReader/setup
Could not open the specified file.

Error in
/Applications/MATLAB_R2013a.app/toolbox/matlab/system/+matlab/+system/+mixin   
/FiniteSource.p>FiniteSource.isDone
(line 39) 

I'm using MATLAB 2013a, on OS X (Mavericks), what should I do? It is working fine on Windows 7.

1条回答
来,给爷笑一个
2楼-- · 2019-07-19 16:39

As we discussed in the comments, the codec that was used to encode the video is may not supported on your Mac. For MATLAB, the supported codecs that the CVST video reader can read in are different between Mac and Windows.

As such, try re-encoding your video into a format that is native to the Mac, like a QuickTime movie file, or an MP4 file. HandBrake is a perfect tool to do this for you.

Also, perhaps try using MATLAB's native VideoReader class to see if you can read the file and extract video frames. Take a look at its documentation for more details: http://mathworks.com/help/matlab/ref/videoreader-class.html.

However, it looks like you have resolved the error, as converting it to a QuickTime movie file worked.

Glad I could help!

查看更多
登录 后发表回答