라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

mmreader class

Create object for reading video files

    Note:   mmreader has been removed. Use VideoReader instead.

Description

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)

Windows®

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

Macintosh

AVI (.avi),
MPEG-1 (.mpg),
MPEG-4 (.mp4, .m4v),
Apple QuickTime Movie (.mov),
and any format supported by QuickTime as listed on http://support.apple.com/kb/HT3775.

Linux®

Any format supported by your installed plug-ins for GStreamer 0.10 or above, as listed on http://gstreamer.freedesktop.org/documentation/plugins.html, including AVI (.avi) and Ogg Theora (.ogg).

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

Construction

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.

Properties

BitsPerPixel

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

Duration

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

FrameRate

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

Height

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

Name

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

NumberOfFrames

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;

Path

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

Tag

User-defined string to identify the object.

Default: ''

Type

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

UserData

Generic field for user-defined data.

Default: []

VideoFormat

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

Width

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

Methods

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.

Examples

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

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

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);
end

% 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?