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.
But how to get to know what video CODECS your MATLAB version supports. Click Here to Know.
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 |
Command line view while decompressing theVideo thorugh FFMPEG command line tool |
6 comments: