vision.VideoFileReader System object

Package: vision

Read video frames and audio samples from video file

Description

The VideoFileReader object reads video frames, images, and audio samples from a video file. The object can also read image files.

Supported Platforms and File Types

The supported file formats available to you depend on the codecs installed on your system.

PlatformSupported File Name Extensions
All PlatformsAVI (.avi)
Windows®Image:
.jpg,.bmp
Video:
MPEG (.mpeg)
MPEG-2 (.mp2)
MPEG-1.mpg

MPEG-4, including H.264 encoded video (.mp4, .m4v)
Motion JPEG 2000 (.mj2)
Windows Media Video (.wmv,.asf, .asx, .asx)
and any format supported by Microsoft DirectShow® 9.0 or higher.
Audio:
WAVE (.wav)
Windows Media Audio File (.wma)
Audio Interchange File Format (.aif, .aiff)
Compressed Audio Interchange File Format(.aifc),
MP3 (.mp3)
Sun Audio (.au)
Apple (.snd)
MacintoshVideo:
.avi
Motion JPEG 2000 (.mj2)
MPEG-4, including H.264 encoded video (.mp4, .m4v)
Apple QuickTime Movie (.mov)
and any format supported by QuickTime as listed on http://support.apple.com/kb/HT3775.
Audio:
Uncompressed .avi
Linux®Motion JPEG 2000 (.mj2)
Any format supported by your installed plug-ins for GStreamer 0.10 or above, as listed on http://gstreamer.freedesktop.org/documentation/plugins.html, including Ogg Theora (.ogg).

Windows XP and Windows 7 x64 platform ships with a limited set of 64-bit video and audio codecs. If a compressed multimedia file fails to play, try one of the two alternatives:

  • Run the 32-bit version of MATLAB® on your Windows XP x64 platform. Windows XP x64 ships with many 32-bit codecs.

  • Save the multimedia file to a supported file format listed in the table above.

If you use Windows, use Windows Media player Version 11 or later.

Construction

videoFReader = vision.VideoFileReader(FILENAME) returns a video file reader System object, videoFReader. The object can sequentially read video frames and/or audio samples from the input video file, FILENAME. Every call to the step method returns the next video frame.

videoFReader = vision.VideoFileReader(Filename,Name,Value) configures the video file reader properties, specified as one or more name-value pair arguments. Unspecified properties have default values.

Code Generation Support
Supports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Generated code for this function uses a precompiled platform-specific shared library.
Code Generation Support, Usage Notes, and Limitations.

To read a file:

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

  2. Call the step method with the input filename, FILENAME, the video file reader object, videoFReader, and any optional properties. See the syntax below for using the step method.

I = step(videoFReader) outputs next video frame.

[Y,Cb,Cr] = step(videoFReader) outputs the next frame of YCbCr 4:2:2 format video in the color components Y, Cb, and Cr. This syntax requires that you set the ImageColorSpace property to 'YCbCr 4:2:2'.

[I,AUDIO] = step(videoFReader) outputs the next video frame, I, and one frame of audio samples, AUDIO. This syntax requires that you set the AudioOutputPort property to true.

[Y,Cb,Cr,AUDIO] = step(videoFReader) outputs next frame of YCbCr 4:2:2 video in the color components Y, Cb, and Cr, and one frame of audio samples in AUDIO. This syntax requires that you set the AudioOutputPort property to true, and the ImageColorSpace property to 'YCbCr 4:2:2'.

[..., EOF] = step(videoFReader) returns the end-of-file indicator, EOF. The object sets EOF to true each time the output contains the last audio sample and/or video frame.

Properties

Filename

Name of video file

Specify the name of the video file as a string. The full path for the file needs to be specified only if the file is not on the MATLAB path.

Default: vipmen.avi

PlayCount

Number of times to play file

Specify a positive integer or inf to represent the number of times to play the file.

Default: inf

AudioOutputPort

Output audio data

Use this property to control the audio output from the video file reader. This property applies only when the file contains both audio and video streams.

Default: false

ImageColorSpace

RGB, YCbCr, or intensity video

Specify whether you want the video file reader object to output RGB, YCbCr 4:2:2 or intensity video frames. This property applies only when the file contains video. This property can be set to RGB, Intensity, or YCbCr 4:2:2.

Default: RGB

VideoOutputDataType

Output video data type

Set the data type of the video data output from the video file reader object. This property applies if the file contains video. This property can be set to double, single, int8, uint8, int16, uint16, int32, or Inherit.

Default: single

AudioOutputDataType

Output audio samples data type

Set the data type of the audio data output from the video file reader object. This property applies only if the file contains audio. This property can be set to double, single, int16, or uint8.

Default: int16

Methods

cloneCreate multimedia file reader object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
infoInformation about specified video file
isDoneEnd-of-file status (logical)
isLockedLocked status for input attributes and non-tunable properties
release Allow property value and input characteristics changes
resetReset internal states of multimedia file reader to read from beginning of file
stepOutput video frame

Examples

Read and Play a Video File

videoFReader = vision.VideoFileReader('viplanedeparture.avi');
videoPlayer = vision.VideoPlayer;
while ~isDone(videoFReader)
  videoFrame = step(videoFReader);
  step(videoPlayer, videoFrame);
end
release(videoPlayer);
release(videoFReader);
Was this topic helpful?