If you’re like most people, you’re likely to find a variety of media files on your computer. You’ll find files with extensions such as .mov, .m4v, .mpg, and .m4a. Although we commonly refer to these types as file formats, the correct definition is they are container formats.
A container format is considered a metafile format. From a high level you can think of a container format as a directory containing one or more types of media along with metadata describing its contents. A QuickTime file, for instance, can contain a variety of media types, including video, audio, subtitles, and chapter information, and contains metadata describing the details of each piece of media it holds.
Each format has a specification that determines the structure of the file. The structure defines not only the technical aspects of the media it contains, such as the media’s duration, encoding, and timing information, but also commonly defines descriptive metadata, such as a movie’s title or an song’s artist information. This metadata can be presented in tools such as iTunes or the iOS Music app, and AV Foundation provides the classes to read and write this type of data in your applications as well.
You’ll use two primary container formats when working with AV Foundation:
- QuickTime: QuickTime is Apple’s proprietary format defined as part of the larger QuickTime architecture. This is an extremely robust and highly specified format that is widely used in both professional and consumer settings. Apple describes this format in great detail in a QuickTime File Format Specification document that you can find on the Apple Developer Connection site. I recommend that all AV Foundation developers read at least the introductory sections of this document because it provides valuable insight that will benefit you when developing media applications.
- MPEG–4: The MPEG-4 Part 14 specification defines the MPEG-4 (MP4) container format. This is an industry standard format derived directly from the QuickTime specification, so the two are very similar in structure and capabilities. The official file extension defined for an MP4 container is .mp4 but a variety of variant extensions are in use, particularly within Apple’s ecosystem. These variant file extensions still use the same basic MP4 container format, but are often used to distinguish the particular media type, as is the case with an m4a audio file, or can additionally indicate the use of extensions to the base MP4 container, as is the case with m4v video files.