Documentation

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.

VideoReader

Create object to read video files

Syntax

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

Description

example

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.

Examples

collapse all

Create VideoReader Object and Read Video

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);
end
whos video
  Name         Size                Bytes  Class    Attributes

  video      240x320x3            230400  uint8              

Input Arguments

collapse all

filename — File namestring

File name, specified as a string.

VideoReader supports these file formats:

Platforms

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

Macintosh

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

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.

Linux®

Any format supported by your installed plug-ins for GStreamer 0.10, as listed on http://gstreamer.freedesktop.org/documentation/plugins.html, 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.

'CurrentTime' — Timestamp of video frame to read0 (default) | numeric scalar

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.

Example: 'CurrentTime',5.6

Data Types: double

'Tag' — String data'' (default) | string

String data, specified as the name-value pair consisting of 'Tag' and a string.

Example: 'Tag','Experiment 109'

Data Types: char

'UserData' — User-defined data[] (default) | any

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

Output Arguments

collapse all

v — Output VideoReader objectVideoReader object

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

Introduced in R2010b

Was this topic helpful?