Supported Video File Formats

What Are Video Files?

For video data, the term "file format" often refers to either the container format or the codec. A container format describes the layout of the file, while a codec describes how to encode/decode the video data. Many container formats can hold data encoded with different codecs.

To read a video file, any application must:

  • Recognize the container format (such as AVI).

  • Have access to the codec that can decode the video data stored in the file. Some codecs are part of standard Windows® and Macintosh system installations, and allow you to play video in Windows Media® Player or QuickTime. In MATLAB®, VideoReader can access most, but not all, of these codecs.

  • Properly use the codec to decode the video data in the file. VideoReader cannot always read files associated with codecs that were not part of your original system installation.

Formats That VideoReader Supports

Use VideoReader to read video files in MATLAB. The file formats that VideoReader supports vary by platform, and have no restrictions on file extensions.

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

Linux®

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).

View Codec Associated with Video File

This example shows how to view the codec associated with a video file, using the mmfileinfo function.

Store information about the sample video file, shuttle.avi, in a structure array named info.

info = mmfileinfo('shuttle.avi');

View the Format field of the structure.

info.Video.Format
ans =

MJPG

The file, shuttle.avi, uses the Motion JPEG codec.

Troubleshooting: Errors Reading Video File

You might be unable to read a video file if MATLAB cannot access the appropriate codec. 64-bit applications use 64-bit codec libraries, while 32-bit applications use 32-bit codec libraries. For example, when working with 64-bit MATLAB, you cannot read video files that require access to a 32-bit codec installed on your system. To read these files, try one of the following:

  • Install a 64-bit codec that supports this file format. Then, try reading the file using 64-bit MATLAB.

  • Re-encode the file into a different format with a 64-bit codec that is installed on your computer.

Sometimes, VideoReader cannot open a video file for reading on Windows platforms. This might occur if you have installed a third-party codec that overrides your system settings. Uninstall the codec and try opening the video file in MATLAB again.

Was this topic helpful?