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.


Create object to read video files


  • v = VideoReader(filename)
  • v = VideoReader(filename,Name,Value)



v = VideoReader(filename) creates object v to read video data from the file named filename.

v = VideoReader(filename,Name,Value) creates the object with additional options specified by one or more name-value pair arguments.


collapse all

Create a VideoReader object for the example movie file, xylophone.mp4.

v = VideoReader('xylophone.mp4');

Read all video frames.

while hasFrame(v)
    video = readFrame(v);
whos video
  Name         Size                Bytes  Class    Attributes

  video      240x320x3            230400  uint8              

Input Arguments

collapse all

File name, specified as a character vector.

VideoReader supports these file formats:


File Formats

All Platforms

AVI, including uncompressed, indexed, grayscale, and Motion JPEG-encoded video (.avi)
Motion JPEG 2000 (.mj2)

All Windows®

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

Windows 7 or later

MPEG-4, including H.264 encoded video (.mp4, .m4v)
Apple QuickTime Movie (.mov)
Any format supported by Microsoft Media Foundation


Most formats supported by QuickTime Player, including:
MPEG-1 (.mpg)
MPEG-4, including H.264 encoded video (.mp4, .m4v)
Apple QuickTime Movie (.mov)

Note: For OS X Yosemite (Version 10.10) and later, MPEG-4/H.264 files written using VideoWriter, play correctly, but display an inexact frame rate.


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

Note: Support is provided for GStreamer 0.10 only, not later versions.

Example: 'myFile.mp4'

Example: '../dir/videos/myFile.avi'

Data Types: char

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: v = VideoReader('myFile.avi','CurrentTime',35.2) creates a VideoReader object to read myFile.avi, starting from the video frame that is 35.2 seconds from the beginning of the file.

collapse all

Timestamp of the video frame to read, specified as the name-value pair consisting of 'CurrentTime' and a numeric scalar. The timestamp is specified in seconds from the start of the video file. The value of CurrentTime can be between zero and the duration of the video.

Note: On some platforms, when you create a VideoReader object, the 'CurrentTime' property might contain a value close to, but not exactly, zero. This variation in the value of the 'CurrentTime' property is due to differences in how each platform processes and reads videos.

Example: 'CurrentTime',5.6

Data Types: double

Text data, specified as the name-value pair consisting of 'Tag' and a character vector.

Example: 'Tag','Experiment 109'

Data Types: char

User-defined data, specified as the name-value pair consisting of 'UserData' and a value of any data type.

Output Arguments

collapse all

Output VideoReader object. After you create a VideoReader object, you can read video files using object functions. See VideoReader for details.

Introduced in R2010b

Was this topic helpful?