A container is a special file format used either to store a single video or audio stream, or to interleave one or more video and audio streams. Containers may also hold other streams, such as the still images used for subtitles and menu highlights on DVDs.
Some video formats require particular containers to be used, and some containers are specific to certain formats of video. For example, MPEG-2 Program Stream (PS) files use a special container generally associated with the .MPEG or .MPG file extensions. While it's possible to use other containers for these files, the standard container is used almost universally.
Reading Streams From A Container
In order to allow simultaneous playback of different streams (such as combining video and audio) they are interleaved so that they don't have to be read in their entirety before playback. The picture shows a single video stream interleaved with 2 audio streams and a subpicture (subtitle) stream. In order to render the various streams for playback they must first be split using special software. For MPEG-2 Program Streams and AVI files this functionality is included in Windows. For other containers its typically handled by DirectShow filters installed by various player software and encoders. In some cases, such as MP4, you may need to add software with this functionality yourself. The Haali Media Splitter can be used to read streams from both the matroska and MP4 containers.
MPEG-2 Program Stream
MPEG-2 Program Streams, which usually use an extension of either .MPG or .MPEG are actually not streams, but rather the container used to store most MPEG-2 video, and related audio streams. As MPEG-2 is a superset of MPEG-1, this includes video in both formats, although you may see MPEG-1 in a similar, but older container. These files typically contain MPEG-2 video and either MPEG-1 Layer 2 or MPEG-2 Layer 2, or AC-3 (Dolby Digital) audio.
MPEG-2 Transport Stream
The MPEG-2 Transport Stream container is designed to deliver multiple sets of streams together that would normally have to be delivered as separate files. Rather than limiting the container to a single video stream, as most containers including the standard MPEG-2 Program Stream are, this container allows multiple video streams to be delivered simultaneously. This makes it suitable for various broadcast type applications like Streaming video across the internet and satellite television. They generally have an extension of .TS. These files typically contain MPEG-2 video and either MPEG-1 Layer 2 or MPEG-2 Layer 2, or AC-3 (Dolby Digital) audio.
VOB
DVD-Video uses a variation on the standard MPEG-2 container. This is generally referred to as the VOB container, because the file extension used on DVDs is .VOB for Video Object. Although there is additional information added that's not part of the original MPEG container, most software designed for reading MPEG files should be able to read streams from the VOB container.
AVI
AVI is the official container for Microsoft's Video for Windows multimedia framework. It can be used for uncompressed video and audio or streams compressed with a VfW Codec. Common codecs for AVI files include DivX, XviD, DV, and Huffyuv. Since it's not designed around a single format or standard, the AVI container doesn't include as much information about the video being stored as more specialized containers like MPEG or MP4. However, that information can still be included in the video and audio streams interleaved in the file.
MP4
MP4 is the official container for MPEG-4 video, as defined by MPEG-4 Part 14. It's based on the container Apple developed for QuickTime. It uses an extension of .MP4, although some files containing only video or audio will incorrectly use extensions of .M4V or .M4A respectively. This is standard for files downloaded from iTunes, with DRM protected files using an extension of .M4P. The streams normally found in the MP4 container are MPEG-4 ASP, MPEG-4 AVC video and AAC audio.
3GP
3GP is a container defined by the MPEG-4 Part 14 specification. It's designed for applications like Cell phone video, where storage limitations require low container overhead. It's similar to the standard MP4 container in most respects. The video normally found in the 3GP container is MPEG-4 (ASP or AVC), which the audio is typically in the form of an AVC stream.
Matroska
Matroska, which uses a file extension of .MKV, is designed to be a universal container for containing nearly any type of video, audio, and subtitle streams available. Rather than focus on the features of a single format or device it supports features used in other containers like AVI and MPEG, and even supports some features not implemented in mainstream codecs, such as Variable Framerate. Although it hasn't been implemented yet, support for interactive menus is planned. Although there is also a matroska Video Codec, it's not widely used. Common streams to find in matroska files include MPEG-4 ASP (DivX, XviD, 3ivX, etc,...) and MPEG-4 AVC (X.264) for video and MP3, AC-3 (Dolby Digital), and AAC for audio.
OGM
OGM is a container intended to be used for codecs developed by the Xiph.Org Foundation. It's a modified version of the foundation's original Ogg container. OGM differs from Ogg in support for video and audio streams in more common formats like MPEG-4 ASP (DivX, XviD, etc,...) and AC-3 (Dolby Digital).
ASF
ASF, which has stood for Advanced Systems Format, Advanced Streaming Format, or Active Streaming Format at various times. It's a Microsoft container used for Windows Media Video and Audio streams. ASF files may have an extension of .ASF, or may use WMA or WMV denoting audio or video.
DVR-MS
DVR-MS is a container based on ASF, but specifically modified for Windows Media Center Edition's DVR functionality. DVR-MS files support MPEG-2 video and audio, as well as AC-3 (Dolby Digital) audio. It's used almost exclusively by the various Windows Media Center Editions, although there are a few tools capable of reading, and in some cases even creating DVR-MS files.
QuickTime
One of the oldest containers still in use, QuickTime is used by Apple's QuickTime encoding and playback software. It uses an extension of .MOV. It's also very closely related to the MP4 container, which was originally based on this container. Video streams found in QuickTime containers are generally MPEG-4 AVC, with audio typically being AAC.
Related Guides
How to play TS files
How to play ASF / WMV files
How to play 3GP files
How to play MPG/MPEG files
How to play OGM files
How to play MP4 files
How to play MOV files
How to play MKV files
How to play AVI
Extract AC3 audio from AVI file
VirtualDub: Joining AVI files
VirtualDub: Splitting AVI files