MATLAB: Am I unable to use a compression codec with AVIFILE using MATLAB 7.7 (R2008b) on Windows XP/Vista x64 machine

6464-bitavireadMATLAB

I am executing the code from the example of AVIFILE in the MATLAB documentation but I always get an error.
t = linspace(0,2.5*pi,40);
fact = 10*sin(t);
fig=figure;
aviobj = avifil('example.avi','compression','CODECINFO')
% I replace CODECINFO with different codecs
[x,y,z] = peaks;
for k=1:length(fact)
h = surf(x,y,fact(k)*z);
axis([-3 3 -3 3 -80 80])
axis off
caxis([-90 90])
F = getframe(fig);
aviobj = addframe(aviobj,F);
end
close(fig)
aviobj = close(aviobj);
My results of trying the 5 compression options:
- 'Indeo3' and 'Indeo5' are not available for 64 bit Windows OS.
- With 'Cinepak' - the codec is not found.
- 'RLE' and 'MSVC' cannot be used with color data.

Best Answer

To resolve this issue in MATLAB 7.7 (R2008b), you may create an uncompressed video using
avifile(filename, 'Compression', 'None')
and then compressing the file using a third party tool like:
- Windows Movie Maker
- Windows Media 9 encoder
- VirtualDub (<http://www.virtualdub.org/>)
- Quicktime Pro
VirtualDub has a command line interface so it is possible to drive it using SYSTEM.
The second workaround is to specify a codec for a compression that is installed. The ones that are included with Windows XP 64 are
* IYUV Intel YUV codec (c:\winnt\system32\iyuv_32.dll)
* MRLE Microsoft RLE codec (c:\winnt\system32\msrle32.dll)
* MSVC Microsoft Video 1 codec (c:\winnt\system32\msvidc32.dll)
For example, to use the Intel YUV codec, use the four-CC code:
aviobj = avifile('myvideo.avi', 'compression', 'IYUV');
Other codecs can be found at http://fourcc.org.
Note there are restrictions with some codecs. For example, some codecs can only be used with grayscale images.