This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

vision.VideoPlayer System object

Package: vision

Play video or display image


The VideoPlayer object can play a video or display image sequences.

    Note:   If you own the MATLAB® Coder™ product, you can generate C or C++ code from MATLAB code in which an instance of this system object is created. When you do so, the scope system object is automatically declared as an extrinsic variable. In this manner, you are able to see the scope display in the same way that you would see a figure using the plot function, without directly generating code from it. For the full list of system objects supporting code generation, see Code Generation Support, Usage Notes, and Limitations in the MATLAB Coder documentation.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


videoPlayer = vision.VideoPlayer returns a video player object, videoPlayer, for displaying video frames. Each call to the step method displays the next video frame.

videoPlayer = vision.VideoPlayer(Name,Value) configures the video player properties, specified as one or more name-value pair arguments. Unspecified properties have default values.

To display video frames:

  1. Define and set up your video player object using the constructor.

  2. Call the step method with the video player object, VideoPlayer, and any optional properties. See the syntax below for using the step method.

step(videoPlayer,I) displays one grayscale or truecolor RGB video frame,I, in the video player.



Caption display on video player window

Specify the caption to display on the video player window as a character vector.

Default: Video


Size and position of the video player window in pixels

Specify the size and position of the video player window in pixels as a four-element vector of the form: [left bottom width height]. This property is tunable.

Default: Dependent on the screen resolution. Window positioned in the center of the screen with size of 410 pixels in width by 300 pixels in height.


cloneCreate video player with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
hideTurn figure visibility off
isLockedLocked status for input attributes and non-tunable properties
isOpenVisible or hidden status for video player figure
release Allow property value and input characteristics changes
resetReset displayed frame number to zero
showTurn figure visibility on
stepPlay video or image sequence


expand all

Read video from a file and set up player object.

videoFReader = vision.VideoFileReader('viplanedeparture.mp4');
videoPlayer = vision.VideoPlayer;

Play video. Every call to the step method reads another frame.

while ~isDone(videoFReader)
   frame = step(videoFReader);

Close the file reader and video player.


Related Examples

Introduced in R2012a

Was this topic helpful?