mmreader class

Create object for reading video files

    Note:   mmreader has been removed. Use VideoReader instead.


Use mmreader with the read method to read video data from a multimedia file into the MATLAB® workspace.

The file formats that mmreader supports vary by platform, as follows (with no restrictions on file extensions):

All Platforms

Motion JPEG 2000 (.mj2)


AVI (.avi),
MPEG-1 (.mpg),
Windows Media® Video (.wmv, .asf, .asx),
and any format supported by Microsoft® DirectShow.


AVI (.avi),
MPEG-1 (.mpg),
MPEG-4 (.mp4, .m4v),
Apple QuickTime Movie (.mov),
and any format supported by QuickTime as listed on


Any format supported by your installed plug-ins for GStreamer 0.10 or above, as listed on, including AVI (.avi) and Ogg Theora (.ogg).

For more information, see Supported Video File Formats in the MATLAB Data Import and Export documentation.


obj = mmreader(filename) constructs obj to read video data from the file named filename. The mmreader constructor searches for the file on the MATLAB path. If it cannot construct the object for any reason, mmreader generates an error.

obj = mmreader(filename,'PropertyName',PropertyValue) constructs the object using options, specified as property name/value pairs. Property name/value pairs can be in any format that the set method supports: name/value string pairs, structures, or name/value cell array pairs.



Bits per pixel of the video data. (Read-only)


Total length of the file in seconds. (Read-only)


Frame rate of the video in frames per second. (Read-only)


Height of the video frame in pixels. (Read-only)


Name of the file associated with the object. (Read-only)


Total number of frames in the video stream. (Read-only)

Some files store video at a variable frame rate, including many Windows Media Video files. For these files, mmreader cannot determine the number of frames until you read the last frame. When you construct the object, mmreader returns a warning and does not set the NumberOfFrames property.

To count the number of frames in a variable frame rate file, use the read method to read the last frame of the file. For example:

vidObj = mmreader('varFrameRateFile.wmv');
lastFrame = read(vidObj, inf);
numFrames = vidObj.NumberOfFrames;


String containing the full path to the file associated with the reader. (Read-only)


User-defined string to identify the object.

Default: ''


Class name of the object: 'mmreader'. (Read-only)


Generic field for user-defined data.

Default: []


String indicating the MATLAB representation of the video format, such as 'RGB24'. (Read-only)


Width of the video frame in pixels. (Read-only)


For backward compatibility, mmreader supports the following VideoReader methods:

getQuery property values for video reader object
getFileFormatsFile formats that VideoReader supports
hasFrameDetermine if frame available to read
readRead video frame data from file
readFrameRead video frame from video file
setSet property values for video reader object

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.


Construct an mmreader object for the example movie file xylophone.mpg and view its properties:

xyloObj = mmreader('xylophone.mpg', 'Tag', 'My reader object');

Read and play back the movie file xylophone.mpg:

xyloObj = mmreader('xylophone.mpg');

nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;

% Preallocate movie structure.
mov(1:nFrames) = ...
    struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
           'colormap', []);

% Read one frame at a time.
for k = 1 : nFrames
    mov(k).cdata = read(xyloObj, k);

% Size a figure based on the video's width and height.
hf = figure;
set(hf, 'position', [150 150 vidWidth vidHeight])

% Play back the movie once at the video's frame rate.
movie(hf, mov, 1, xyloObj.FrameRate);
Was this topic helpful?