Products & Services Solutions Academia Support User Community Company

Learn more about Video and Image Processing Blockset   

mplay - View video from MATLAB workspace, multimedia file, or Simulink model

Syntax

mplay
mplay('filename.avi')
mplay('filename.avi',FPS)
mplay(A)
mplay(A,FPS)
mplay({line_handles})
mplay({'block',PORT})

Description

mplay opens an MPlay GUI that allows you to view video from files or the MATLAB workspace. The MPlay GUI does not play audio.

mplay('filename.avi') connects the MPlay GUI to the specified AVI file. You can also view video signals in Simulink models.

mplay('filename.avi',FPS) plays the specified frame rate in frames per second, (FPS). The FPS value equals that of the frame rate specified in the file.

mplay(A) connects the MPlay GUI to the variable in the MATLAB workspace, A.

mplay(A,FPS) plays the specified frame rate in frames per second, FPS. The FPS value defaults to 20.

mplay({line_handles}) connects the MPlay GUI to one or three Simulink signal lines to display, where all signals must originate from the same block.

mplay({'block',PORT}) connects the MPlay GUI to the output signal of the specified block, 'block', on output port port. The port index value defaults to 1.

Inputs

A

A is a variable in the MATLAB workspace, which must have one of the following formats:

  • MATLAB movie structure

  • Intensity video. This input is an M-by-N-by-T, or M-by-N-by-1-by-T array, where the size of each frame is M-by-N and there are T image frames.

  • RGB video array. This input is an M-by-N-by-3-by-T array, where the size of each RGB image is M-by-N-by-3 and there are T image frames.

For performance considerations, the video input A data type converts to unit8 as follows:

Supported Data TypesConverted to uint8
double
single
int8
uint8 
int16
uint16 
int32
uint32
Boolean
Fixed point

block

The block is a full path to a specified Simulink blockset block. To get the full block path name of the currently selected Simulink block, issue the command mplay({gcb,1}) on the MATLAB command line.

filename.avi

Filename.avi is a specified AVI file.

FPS

FPS stands for frames per second. You can specify the frame rate in frames per second.

line_handles

line_handles are Simulink signal lines. To get the handles to the Simulink signals, line_handles, issue the command mplay({gsl}) on the MATLAB command line.

port

The port refers to a Simulink block output port number.

Examples

Play a video created in MATLAB workspace.

fig=figure;  % create a video
set(gca,'xlim',[-80 80],'ylim',[-80 80],'NextPlot', ...
'replace','Visible','off');
x = -pi:.1:pi;
radius = 0:length(x);
video = []; % initialize video variable
   for i=length(x):-1:1
     patch(sin(x)*radius(i),cos(x)*radius(i), ...
[abs(cos(x(i))) 0 0]);
     F = getframe(gca);
    video = cat(4,video,F.cdata); % video is MxNx3xT
   end
   close(fig);
   mplay(video); % display a video

Alternatives

Access this GUI by selecting Tools > MPlay Video Viewer.

See Also

To Video Display | Video Viewer

Tutorials

How To

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS