AmyNerd
AmyNerd

Reputation: 21

Can't read an .avi file to matlab using VideoRead

Code:

A = aviread('firstAttempt_1395344631.avi');

Response:

Error using VideoReader/init (line 447)  
Failed to initialize internal resources.  

Error in VideoReader (line 132)  
            obj.init(fileName);  

Error in untitled (line 1)  
A = VideoReader('firstAttempt_1395344631.avi');  

Any suggestions? I can't use aviread, as I get the response:

Error using aviread (line 148)  
Only uncompressed AVI movies can be read on UNIX.  

Error in untitled (line 1)  
A = aviread('firstAttempt_1395344631.avi');  

Upvotes: 2

Views: 10089

Answers (3)

Ananth Reddy
Ananth Reddy

Reputation: 317

It would be better to read the .avi video file using VideoReader function than aviread. VideoReader function gives an object of video to work upon.

Upvotes: 0

Stephen
Stephen

Reputation: 543

The issue is that while VideoReader supports compressed video, it doesn't support compressed video when run from Unix. If you use the (deprecated) aviread, it will give you this error message:

Error using aviread (line 147)
Only uncompressed AVI movies can be read on UNIX.

Fortunately, unix has good tools. You can use ffmpeg. On ubuntu linux, install with apt-get install ffmpeg, and on mac, if you have homebrew, then just brew install ffmpeg.

Then use ffmpeg to uncompress. Using the first reference I found on google (http://forum.doom9.org/archive/index.php/t-121280.html), something like this should work:

ffmpeg -i input.avs -an -vcodec rawvideo -y output.avi

I tried it myself, and the new file (say, output.avi) still doesn't work with aviread but now it does work with VideoReader. Easy!

Upvotes: 10

Divakar
Divakar

Reputation: 221704

Have you tried running this directly? -

A = VideoReader('firstAttempt_1395344631.avi');

As far as I know VideoReader supports compressed videos as well. Take a look at it's documentation here.

This will create A as a multimedia reader object, that is basically a structure and it holds data for all the frames, along with the information about the video, like frame rate, resolution, number of frames, etc.

Take a look here for some examples of frame specific processing and how to access different components of the reader object that includes metadata associated with the video.

Upvotes: 0

Related Questions