I am working with video in Matlab, and having trouble.
I'm using Matlab R2012a on a Mac OS X 10.8.2 (Mountain Lion).
I can load a video in using VideoReader
and grab a frame like so:
vid = VideoReader('movie.mp4');
pic = read(vid, 20);
imshow(pic);
However, what I see in Matlab is..
Instead of this (in VLC)..
Not only is movement being garbled (the turquoise truck) but the green truck in the background is actually gone by that frame. I'm guessing the codec is compressing the movie in such a way that Matlab isn't compensating for. However, I can't find any other video format that Matlab will accept.
The video shown is mpeg4, yuv420p. I see Matlab mentions a lot about mpeg2 being supported and AVI being the preference. I've converted the video to all sorts of formats using ffmpeg
but Matlab has given the following error for every other file format:
Error using VideoReader/init (line 447)
Failed to initialize internal resources.Error in VideoReader (line 132)
obj.init(fileName);
Any thoughts?
VideoReader
, it uses QuickTime for the codecs on Mac. Have you tried this on Windows? (it uses DirectShow on Windows) Also, you could try updating QuickTime to see if that helps. – wakjah