Note: it seems that I only have this problem with Mac OS X Lion. It would still be very useful to find a solution.
VideoReader won't read videos created by VideoWriter
5 views (last 30 days)
Show older comments
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.
Accepted Answer
More Answers (2)
Sean de Wolski
on 27 Mar 2012
Can you read other avi files? Perhaps the stock 'rhinos.avi'?
v = VideoReader('rhinos.avi');
R = v.read;
implay(R)
Rodrigo
on 20 Apr 2012
Hi Ben,
I'm having the same problem and I'm using Snow Leopard (10.6.8). Did you figure out the problem?
0 Comments
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!