MATLAB: VideoReader won’t read videos created by VideoWriter

videoreadervideowriter

As stated in the title, I'm having difficulty getting VideoReader to read videos written by VideoWriter. In particular, I'm using VideoWriter to generate a video that fades from one image to another, with the following code:
fps = 30;
duration = 3;
frames = fps*duration; % Fix an even number of frames.
f = linspace(1,0,frames);
im1 = imread(im1path);
im2 = imread(im2path);
vid = VideoWriter(vidpath,'Uncompressed AVI');
vid.FrameRate = fps;
open(vid);
for i = 1:frames
imagesc(f(i)*im1+(1-f(i))*im2);
drawnow;
curframe=getframe;
writeVideo(vid,curframe);
end;
close(vid);
This successfully creates the video file in avi format, and it works fine to view it with VLC player. However, when I try to reload the video using VideoReader, I get the following error:
Error using VideoReader/init (line 442)
Initialization Failed. This file may be corrupt or a codec may
need to be installed to read the file properly.
Error in VideoReader (line 132)
obj.init(fileName);
Has anyone experienced this issue before? I've tried generating movies in other ways with VideoWriter (e.g., taking a set of frames from an existing AVI movie and writing them to a new file), and have the same problem when loading the video back into matlab. In case this is relevant, here are some details about the files I've created, derived from MediaInfo:
Format: AVI
Video format: RGB
Codec ID: 0x00000000
Codec ID/Info: Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24, and 32 bpp contain raw RGB samples
Thanks for any help.

Best Answer

Yes, the problem turned out to be that I had the DivX codec pack installed on the computer with OS X Lion. When I uninstalled DivX, MATLAB was able to read these videos. The OS didn't actually matter.
Related Question