How to resolve MATLAB Problem With "aviread" or "VideoReader" command, while reading the avi file? (Unable to locate decompressor to decompress video stream)

Very often while doing our projects in image/video processing we require our MATLAB to read the video file for us. For that we use "aviread" & "VideoReader" commands, but in 50% (or may be 80%) of the cases when the video file is not an example file of MATLAB (i.e., its a downloaded file from internet or captured from a camera), its Compressed with a codec which is not supported by MATLAB. And it throws an error like..."Unable to locate decompressor to decompress video stream".

So how to resolve this issue..?
There are many ways:

1. Using a codec to re-compress the video file, with the codec supported by your matlab.

2. Use of RAW video while importing. RAW video means it is not compressed by any of the codecs, so the decompression of the same is not required. Thus MATLAB will be able to open the video file, without searching for the video codecs.

# To decompress your video file to a RAW video, first download FFMPEG application from sourceforge.net (click on the link).
# After downloading the archived file, say you extracted to the drive root D:\. Though not necessary to extract the FFMPEG to drive root you can extract it any folder, but it is advised since its a command line tool & keeping it in root of the drive will reduce the command size & likewise your work.
# suppose in the location there is the avi file that you require to open in MATLAB, of whose name is "v1.avi". (Which was previously unable to open in MATLAB.)
# open the command line through typing "cmd" in the run window.
# then type:    ffmpeg -i v1.avi -vcodec rawvideo v2.avi
#After the necessary processing, a new video file "v2.avi" will be created. Which is much larger in terms of file size than the initial as it is uncompressed.
#now use the new video file in the MATLAB. It should now be read, without any error.


Screenshots:
Use Of FFMPEG to decompress the video file
Use Of FFMPEG to decompress the video file
Command line view while decompressing theVideo thorugh FFMPEG command line tool
Command line view while decompressing theVideo thorugh FFMPEG command line tool


6 comments:

  1. I tried that too, but still can't find the solution as it says :
    D:>'ffmpeg' is not recognized as an internal or external command, operable program or batch file.

    ReplyDelete
    Replies
    1. You might have extracted the ffmpeg application to a different location, as the command prompt is not able to find it, this error is occurring. Thus instead of using D: as the current directory use the folder at which the application have been extracted!

      Delete
  2. Thanks i have this issue but unfortuantely still an error
    ??? Error using ==> aviread at 76
    Error getting frame data.

    Error in ==> usingfilter3 at 6
    video = aviread('v2.avi');

    ReplyDelete
    Replies
    1. Have you followed all the steps for decompressing the video??? If yes....n it doesn't work.....
      Try to convert the video into frames first... http://www.divilabs.com/2013/11/extracting-saving-of-frames-from-video.html

      And then make a video file through those frames....http://www.divilabs.com/2013/12/create-video-file-from-sequence-of.html

      Since the video file is created by MATLAB...it will also be able to play/open it...!

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Yes i did! I am constantly getting errors like
    ??? Error using ==> aviread at 76
    Error getting frame data.
    or
    ??? MATLAB:read:readTimedOut

    Error in ==> mmreader.read at 74
    videoFrames = read(getImpl(obj), index);
    I am currently using r2009a ver of MATLAB

    Read more: http://www.divilabs.com/2014/01/how-to-resolve-matlab-problem-with.html#ixzz32prWUDIC

    ReplyDelete