Containers are containers that hold objects. Container formats are used for storing and transferring different data formats and provide the structure in which different data formats are combined. Most often, container formats are used for transferring audio and video data and contain the data ofvideo and audio codecs. However, they can also be used for only one file format, e.g. only for the files of audio codecs.
The structure of the containers can be relatively simple as in Audio Video Interleave( AVI), which consists of the header, the video and audio data and the trailer. Other structures are much more elaborate and include fields for embedding subtitles, for fonts, texts, markup information, images and forms. For audio and video applications, different compression files for audio and video reside within the container. For example, Real Networks' RealMedia container format contains containers for RealAudio and RealVideo streams, Microsoft's Advanced Streaming Format( ASF) contains Microsoft's proprietary audio and video formats, and MP4 containers can contain video streams, audio, audiobooks, ringtones, and other files.
Not every audio codec and video codec is supported by every container format. That's why you have to pay attention to the compatibilities of codecs to container formats. For example, the MP4 container format is compatible with video codec H.264 and audio codec Advanced Audio Coding( AAC). With Matroska Video( MKV) there is a container format which is relatively flexible and supports several audio codecs.