4
votes

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..

enter image description here

Instead of this (in VLC)..

enter image description here

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?

1
According to the docs for 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

1 Answers

3
votes

Got it.

Thanks to @wakjah for the tip about QuickTime. A video editor friend suggested MPEG StreamClip to convert to the QuickTime format.

This tool took my mp4 file and let me Export as QuickTime.

Sure enough, Matlab loaded it up the mov file no problem and the artifacts are gone.

Cheers.