VideoReader.getFileFormats

Class: VideoReader

File formats that VideoReader supports

Syntax

formats = VideoReader.getFileFormats()

Description

formats = VideoReader.getFileFormats() returns an array of audiovideo.FileFormatInfo objects that indicate which formats VideoReader can read on the current system. Each object has the following properties: Extension, Description, ContainsVideo, and ContainsAudio.

Tips

  • On Windows® and UNIX® systems, the list of file formats does not always contain all the formats that VideoReader can read on your system. getFileFormats returns a platform-dependent, static list of formats that VideoReader can read on most systems.

  • On all systems, VideoReader cannot always read a particular video file even if getFileFormats lists its format. For more information, see Supported Video File Formats.

Output Arguments

formats

Array of audiovideo.FileFormatInfo objects, which have the following properties:

ExtensionFile extension.
DescriptionText description of the file format.
ContainsVideoWhether VideoReader can read video from this format.
ContainsAudioWhether VideoReader can read audio from this format.

To convert this array to a filter list for dialog boxes generated with uigetfile, use the getFilterSpec method with the following syntax:

filterSpec = getFilterSpec(formats)

The filter list includes 'All Video Files' in the first row of the cell array, and 'All Files (*.*)' in the last row.

Examples

View the list of file formats that VideoReader supports on your system:

VideoReader.getFileFormats()

On a Windows system, this list appears as follows:

Video File Formats:
    .asf - ASF File
    .asx - ASX File
    .avi - AVI File
    .mj2 - Motion JPEG2000
    .mpg - MPEG-1
    .wmv - Windows Media Video

Create a dialog box to select a video file:

% Get the supported file formats.
formats = VideoReader.getFileFormats();

% Convert to a filter list.
filterSpec = getFilterSpec(formats);

% Create the dialog box.
[filename, pathname] = uigetfile(filterSpec);

Check whether VideoReader can read an .avi file on the current system:

fmtList = VideoReader.getFileFormats();

if any(ismember({fmtList.Extension},'avi'))
     disp('VideoReader can read AVI files on this system.');
else
     disp('VideoReader cannot read AVI files on this system.');
end

See Also

Was this topic helpful?