MATLAB Answers


Reading MP4 Video files with Matlab in Win7

Asked by Emmanuel on 9 Mar 2011
Latest activity Answered by timmdd pan on 19 Apr 2016


I plan to do image processing on frames from .mp4 (h264) video files, but it seems I cannot get matlab to read the video files first.

The VideoReader class help does not list .mp4 as a supported file type, but accepts "any format supported by Microsoft DirectShow". The Windows player on my machine does read my mp4s, but matlab does not. Updating my codecs with the k-lite codec pack does nothing better.

I searched for solutions before posting here :

- videoIO library Unfortunately requires installation process that is beyond my knowledge (compilation, environment variables ...)

- video.MultimediaFileReader This does not work either, although I have the Video Processing blockset installed.

I know I can transform my mp4 into AVI using VirtualDub or something, but doing the whole process inside Matlab would save hours of work as I have many videos to analyse.

Thank you if anyone can help.



Log in to comment.

8 Answers

Answer by Emmanuel on 14 Jun 2011
 Accepted Answer

R2011b pre-release now supports mpeg-4 and .mov in videoreader. (see p. 13) I have not tested it yet (will probably wait for the final release), but this is good news!


Log in to comment.

Answer by Joseph
on 25 May 2011

I am having the same issue as you. I downloaded the videoIO toolbox with the precompiled binaries for Windows XP, however it does not read in my mp4 video files. I don't think it is a missing codec, as WMP plays the file just fine.

There is apparently VideoReader in Matlab 2010b and newer; however I am running R2009a and only have access to R2010a at the moment. Looking into getting R2010b or newer. Wish there was an easier solution. Did you ever figure out your problem? I see your post is approximately 3 months old.


Log in to comment.

In the earlier versions of MATLAB with mmreader you can read a video file and this function supports most of the video formats.If you have the latest version of MATLAB then you should try using VideoReader()

For more information refer to the below link

Let me know if it works for you :)



Log in to comment.

Answer by Emmanuel on 27 May 2011

I have 2010b and both mmreader and Videoreader fail to open my .mp4 files, even though Windows reader accepts to read them.

The problem remains.

The solution I chose for my last work is to transform .mp4 into separate .jpg frames with another software, and work on frames with matlab.


Log in to comment.

Which software did you use to extract frames ???


Log in to comment.

Answer by Emmanuel on 30 May 2011

I used a famous computer graphics suite, but I wish I could use Matlab !


Log in to comment.

Answer by Marc Vivet on 17 Apr 2012

You can use the Matlab VideoUtils toolbox:

It is very easy to use.


Log in to comment.

Answer by timmdd pan on 19 Apr 2016

This works but I found this: not available by now? may try to let mp4 to mkv or something?


Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!