MATLAB: Do I receive the error “Failed to open file” when I read an AVI file using AVIREAD command on MATLAB 7.8 (R2009a)

MATLAB

I have an image processing program that I have written that has worked fine for the last 6-8 months, and suddenly last week it stopped working. I have tracked the problem down to AVI file handling. I can no longer open them. I have tried rebooting the machine and reinstalling MATLAB. But nothing seems to work. I have ensured that I have permissions to read and write on the file as well as the directory in which the file resides. Using the following commands, I get the following errors, it happens for any filename, whether the file has been used before or not:
>> clear all
>> clear mex
>> test = avifile('avitest.avi')
??? Error using ==> avi
Failed to open file.
Error in ==> avifile.avifile at 173
aviobj.FileHandle = avi('open',filename);
>> mov=aviread('Filename.avi')
??? Error using ==> aviread at 76
Unable to open file.

Best Answer

MATLAB 7.8 (R2009a) uses a DLL file from the Windows Media API to read and write AVI files. For 32 bit Windows, this file is C:\Winnt\system32\avifil32.dll. If this file is corrupt, then MATLAB will not be able to read or write AVI files, and it will throw the error ''Failed to open file".
One way to verify this is by opening an existing AVI file from any other application which uses the same Windows API. One such application is MakeAVI available from SourceForge, available here:
If the API is corrupt then MakeAVI will also throw an error.
In order to restore the Windows API you may reinstall your operating system or contact your system administrator for assistance.