VideoReader Create object to read video files
collapse all in page
Syntax v = VideoReader(filename)
example
v = VideoReader(filename,Name,Value)
Description v = VideoReader(filename) creates object v to read video data from the file named filename.
example
v = VideoReader(filename,Name,Value) creates the object with additional options specified by one or more namevalue 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 name string File name, specified as a string. VideoReader supports these file formats: Platforms
File Formats
All Platforms
AVI, including uncompressed, indexed, grayscale, and Motion JPEGencoded video (.avi) Motion JPEG 2000 (.mj2)
All Windows
®
MPEG1 (.mpg) ® Windows Media Video (.wmv, .asf, .asx) ® ® Any format supported by Microsoft DirectShow
Windows 7 or later
MPEG4, 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: MPEG1 (.mpg) MPEG4, including H.264 encoded video (.mp4, .m4v) Apple QuickTime Movie (.mov) 3GPP 3GPP2 AVCHD
DV Linux
®
Any format supported by your installed plugins for GStreamer 0.10, as listed onhttp://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
NameValue Pair Arguments Specify optional commaseparated 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 asName1,Value1,...,NameN,ValueN. Example: v = VideoReader('myFile.avi','CurrentTime',35.2) creates a VideoReaderobject 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 read 0 (default) | numeric scalar Timestamp of the video frame to read, specified as the namevalue 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 namevalue pair consisting of 'Tag' and a string. Example: 'Tag','Experiment 109' Data Types: char
'UserData' — Userdefined data [] (default) | any Userdefined data, specified as the namevalue pair consisting of 'UserData' and a value of any data type.
Output Arguments
collapse all
v — Output VideoReader object VideoReader object Output VideoReader object. After you create a VideoReader object, you can read video files using object functions. See Using VideoReader Objects for details.
More About Read Video Files
See Also mmfileinfo | VideoWriter
Introduced in R2010b