MATLAB: Do I get an errorWithFileClose error when I use AVIREAD in MATLAB 7.8 (R2009a) on Linux

MATLABmovie

When I run the command:
aviread('bit16avi.avi')
on Linux, I get an error:
??? Error using ==> aviread>errorWithFileClose at 419 Bitmap data must be 8-bit Index images or 24-bit TrueColor images
Error in ==> aviread at 225
errorWithFileClose('MATLAB:aviread:invalidColorBitDepth','Bitmap data must
be 8-bit
Index images or 24-bit TrueColor images', fid);
Here is the output of aviinfo('bit16avi.avi'):
Filename: 'bit16avi.avi'
FileSize: 541432
FileModDate: '09-Jun-2009 10:33:52'
NumFrames: 22
FramesPerSecond: 4.99251123315027
Width: 128
Height: 96
ImageType: 'truecolor'
VideoCompression: 'none'
Quality: 42949

Best Answer

The video file is a 16 bit AVI file, which is not the most conventional kind of AVI file. Most AVI files are 8 bits per channel or 24 bpp.
Although this file can be read with MMREADER on Windows, AVIREAD and MMREADER fail to read this file on Linux. This is because GStreamer on Linux does not have the appropriate plugin to read this kind of AVI file. This a limitation of the GStreamer plugin.
A workaround is to use MMREADER on Windows to read this file and write it out as an uncompressed AVI file with 8 bits per channel. Then you can read that uncompressed AVI file on your Linux machine.
Here is an example of the conversion code to be run in Windows:
% Read in AVI file and get frames
readerobj = mmreader('bit16avi.avi', 'tag', 'myreader1');
vidFrames = read(readerobj);
% Get the number of frames
numFrames = get(readerobj, 'numberOfFrames');
% Add frames into a MATLAB movie
for k = 1 : numFrames
mov(k).cdata = vidFrames(:,:,:,k);
mov(k).colormap = [];
end
% Play movie in MATLAB
movie(mov);
% Save movie as AVI file to be read in Linux
movie2avi(mov,'output.avi','compression','none');