Media container formats (file types)

The format of audio and video media files is defined in two parts (three if a file has both audio and video in it, of course): the audio and/or video codecs used and the media container format (or file type) used. In this gude, we'll look at the container formats used most commonly on the web, covering basics about their specifications as well as their benefits, limitations, and ideal use cases.

WebRTC does not use a container at all. Instead, it streams the encoded audio and video tracks directly from one peer to another using MediaStreamTrack objects to represent each track. See Codecs used by WebRTC for information about codecs commonly used for making WebRTC calls, as well as browser compatibility information around codec support in WebRTC.

Common container formats

While there are a vast number of media container formats, the ones listed below are the ones you are most likely to encounter. Some support only audio while others support both audio and video. The MIME types and extensions for each are listed.The most commonly used containers for media on the web are probably MPEG-4 (MP4), QuickTime Movie (MOV), and the Wavefile Audio File Format (WAV). However, you may also encounter MP3, Ogg, WebM, AVI, and other formats. Not all of these are broadly supported by browsers, however.Some combinations of container and codec are sometimes given their own file extensions and MIME types as a matter of convenience, or because of their ubiquity. For example, an Ogg file with only an Opus audio track is sometimes referred to as an Opus file, and might even have the extension .opus. But it's still actually just an Ogg file.

In other cases, a particular codec, stored in a certain container type, is so ubiquitous that the pairing is treated in a unique fashion. A good example of this is the MP3 audio file, which is in fact an MPEG-1 container with a single audio track encoded using MPEG-1 Audio Layer III encoding. These files use the audio/mp3 MIME type and the .mp3 extension, even though their containers are just MPEG.

3GP

The 3GP media container is used to encapsulate audio and/or video that is specifically intended for transmission over cellular networks for consumption on mobile devices. The format was designed for use on 3G mobile phones, but can still be used on more modern phones and networks. However, the improved bandwidth availability and increased data caps on most networks has reduced the need for the 3GP format. However, this format is still used for slower networks and for lower-performance phones.

The format is derived from the ISO base media file format and MPEG-4, but is specifically streamlined for lower bandwidth scenarios.

Video codecs

Codec Browser support
Chrome Edge Firefox Safari
H.263     Yes1  
H.264     Yes1,2  
MPEG-4 Part 2 (MP4v-es)     Yes1  
VP8     Yes1  

[1] FIrefox only supports 3GP on OpenMAX-based devices, which currently means the Boot to Gecko (B2G) platform.

[2] Firefox support for H.264 relies upon the operating system's media infrastructure, so it is available as long as the OS supports it.

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
AMR-NB     Yes1  
AMR-WB     Yes1  
AMR-WB+     Yes1  
AAC-LC     Yes1,2  
HE-AAC v1     Yes1,2  
HE-AAC v2     Yes1,2  
MP3     Yes1  

[1] FIrefox only supports 3GP on OpenMAX-based devices, which currently means the Boot to Gecko (B2G) platform.

[2] Firefox support for H.264 relies upon the operating system's media infrastructure, so it is available as long as the OS supports it.

ADTS

Audio Data Transport Stream (ADTS) is a container format specified by MPEG-4 Part 3 for audio data, intended to be used for streamed audio, such as for Internet radio. It is, essentially, an almost bare stream of AAC audio data, comprised of ADTS frames with a minimal header.

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
AAC     Yes1  
MP3     Yes  

[1] Firefox support for H.264 relies upon the operating system's media infrastructure, so it is available as long as the OS supports it.

FLAC

The Free Lossless Audio Codec (FLAC) is a lossless audio codec; there is also an associated simple container format, also called FLAC, that can contain this audio. The format is not encumbered by any patents, so its use is safe from interference. FLAC files can only contain FLAC audio data.

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
FLAC     Yes  

MPEG/MPEG-2

The MPEG-1 and MPEG-2 file formats are essentially identical. Created by the Moving Picture Experts Group (MPEG), these formats are widely used in physical media, including as the format of the video on DVD media. On the internet, perhaps the most common use of the MPEG file format is to contain Layer_III/MP3 sound data; the resulting files are the wildly popular MP3 file used by digital music devices around the world. The main differences between MPEG-1 and MPEG-2 take place in the media data formats rather than the container format.

MPEG-1 was introduced in 1992; MPEG-2 was introduced in 1996.

Video codecs

Codec Browser support
Chrome Edge Firefox Safari
MPEG-1 Part 2     No  
MPEG-2 Part 2     No  

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
MPEG-1 Audio Layer I     No  
MPEG-1 Audio Layer II     No  
MPEG-1 Audio Layer III (MP3)     Yes  

MPEG-4

MPEG-4 is the latest version of the MPEG file format. There are two versions of the format, defined in parts 1 and 14 of the specification. MP4 is a popular container today, as it supports several of the most-used codecs and is broadly supported.

The original MPEG-4 Part 1 file format was introduced in 1999; the version 2 format, defined in Part 14, was added in 2003. The MP4 file format is derived from the ISO base media file format, which is directly derived from Apple's Unknown prefix: interwiki..

Video codecs

Codec Browser support
Chrome Edge Firefox Safari
AV1     Yes1  
H.263     No  
H.264     Yes2  
MPEG-4 Part 2 Video     No  
VP9     Yes  

[1] Firefox support for AV1 is currently disabled by default; it can be enabled by setting the preference media.av1.enabled to true.

[2] Firefox support for H.264 relies upon the operating system's media infrastructure, so it is available as long as the OS supports it.

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
AAC     Yes1  
FLAC     Yes  
MPEG-1 Audio Layer III (MP3)     Yes  
Opus     Yes  

[1] Firefox support for H.264 relies upon the operating system's media infrastructure, so it is available as long as the OS supports it.

Ogg

The Ogg container format is a free and open format maintained by the Xiph.org Foundation. The Ogg framework also defines patent unencumbered media data formats, such as Theora, Vorbis, and Opus. Xiph.org documents about the Ogg format are available on their web site.

Video codecs

Codec Browser support
Chrome Edge Firefox Safari
Theora     Yes  
VP8     Yes  
VP9     Yes  

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
FLAC     Yes  
Opus     Yes  
Vorbis     Yes  

QuickTime

The QuickTime file format (QTFF) was created by Apple for use by its media framework of the same name. It supports any sort of time-based data, including audio and video media, text tracks, and so forth. QuickTime files are primarily supported by macOS, but for a number of years, QuickTime for Windows was available to access them on Windows. However, QuickTime for Windows is no longer supported by Apple as of early 2016, and should not be used, as there are known security concerns. However, Windows Media Player now has integrated support for  QuickTime version 2.0 and earlier files; support for later versions of QuickTime requires third-party additions.

A number of third-party components are available for QuickTime, some of which add support for additional codecs.

Because QuickTime support is, for all intents and purposes, primarily available on Apple devices, it is no longer widely used on the internet. Apple itself generally now uses MP4 for video. While QTFF served as the basis for the MPEG-4 file format, there are differences and the two are not quite interchangeable.

Video codecs

Codec Browser support
Chrome Edge Firefox Safari
Cinepak     No  
Component Video     No  
DV     No  
H.261     No  
H.263     No  
H.264     No  
MPEG-2     No  
MPEG-4 Part 2 Video     No  
Motion JPEG     No  
Sorenson Video 2     No  
Sorenson Video 3     No  

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
AAC     No  
ALaw 2:1     No  
Apple Lossless (ALAC)     No  
HE-AAC     No  
MPEG-1 Audio Layer III (MP3)     No  
Microsoft ADPCM     No  
µ-Law 2:1 (u-Law)     No  

WAVE (WAV)

The Waveform Audio File Format (WAVE), usually referred to simply as WAV due to its filename extension being .wav, is a format developed by Microsoft and IBM to store audio bitstream data. Most WAV files contain audio in linear PCM format.

It is derived from the Resource Interchange File Format (RIFF), and as such is similar to other formats such as Apple's AIFF.

The WAVE format was first released in 1991.

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
ADPCM (Adaptive Differential Pulse Code Modulation)     No  
GSM 06.10     No  
LPCM (Linear Pulse Code Modulation)     Yes  
MPEG-1 Audio Layer III (MP3)     No  
µ-Law (u-Law)     No  

WebM

WebM is a format based on Matroska which is designed specifically for use in modern web environments. It's based entirely on free and open technologies and primarily uses codecs that are in turn free and open, although some products support other codecs in WebM containers as well.

WebM was first introduced in 2010.

Video codecs

Codec Browser support
Chrome Edge Firefox Safari
AV1     Yes1  
H.264     Yes2  
VP8     Yes  
VP:9     Yes  

[1] Firefox support for AV1 is currently disabled by default; it can be enabled by setting the preference media.av1.enabled to true.

[2] Firefox support for H.264 relies upon the operating system's media infrastructure, so it is available as long as the OS supports it.

Audio codecs

Codec Browser support
Chrome Edge Firefox Safari
Opus     Yes  
Vorbis     Yes  

Choosing the right container

There are a few factors to consider when selecting the best container or containers to use for your media. The relative importance of each will depend on your needs, your license requirements, and the compatibility requirements of your target audience.

Guidelines

The best choice also depends on what you'll be doing with the media. Playing back media is a different thing than recording and/or editing it. If you're going to be manipulating the media data, using an uncompressed format can improve performance, while using a lossless compressed format at least prevent accumulation of noise as compression artifacts are multiplied with eac re-compression that occurs.

  • If your target audience is likely to include users on mobile, especially on lower-end devices or on slow networks, consider providing a version of your media in a 3GP container with appropriate compression.
  • If you have any specific encoding requirements, make sure the container you choose supports the appropriate codecs.
  • If you want your media to be in a non-proprietary, open format, consider using one of the open container formats such as FLAC (for audio) or WebM (for video).
  • If for any reason you are only able to provide media in a single format, choose a format that's available on the broadest selection of devices and browsers, such as MP3 (for audio) or MP4 (for video and/or audio).
  • If your media is audo-only, choosing an audio-only container format likely makes sense. Now that the patents have all expired, MP3 is a widely supported and good choice. WAVE is good, but uncompressed, so be aware of that before using it for large audio samples. FLAC is a very good choice, due to its lossless compression, if the target browsers all support it.

Unfortunately, neither of the relatively major lossless compression formats (FLAC and ALAC) are universally supported. FLAC is the more broadly supported of the two, but is not supported by macOS without additional software installed, and is not supported at all on iOS. If you need to offer lossless audio, you may need to provide both FLAC and ALAC to get close to universal compatibility.

Container selection advice

The tables below offer suggested containers to use in various scenarios. These are just suggestions. Be sure to consider the needs of your application and your organization before selecting a container format.

Audio-only files

If you need... Consider using this container format
Compressed files for general-purpose playback MP3 (MPEG-1 Audio Layer III)
Losslessly compressed files FLAC with ALAC fallback
Uncompressed files WAV

Now that MP3's patents have all expired, the choice of audio file format has become much easier to make. It's no longer necessary to choose between MP3's broad compatibility and the need to pay royalties when using it.

Video files

If you need... Consider using this container format
General purpose video, preferably in an open format WebM (ideally with MP4 fallback)
General purpose video MP4 (ideally with WebM or Ogg fallback)
High compression optimized for slow connections 3GP (ideally with MP4 fallback)
Compatibility with older devices/browsers QuickTime (ideally with AVI and/or MPEG-2 fallback)

These suggestions make a number of assumptions. You should carefully consider the options before making a final decision, especially if you have a lot of media that will need to be encoded.

Maximizing compatibility with multiple containers

To optimize compatibility, it's worth considering providing more than one version of media files, using the <source> element to specify each source within the <audio> or <video> element. For example, you can offer an Ogg or WebM video as the first choice, with a fallback in MP4 format. You could even choose to offer a retro-like QuickTime or AVI fallback for good measure.

To do this, you create a <video> (or <audio>) element with no src attribute. Then add child <source> elements within the <video> element, one for each version of the video you offer. This can be used to offer various versions of a video that can be selected depending on bandwidth availability, but in our case, we'll use it to offer format options.

In the example shown here, a video is offered to the browser in two formats: WebM and MP4.

The video is offered first in WebM format (with the type attribute set to video/webm). If the user agent can't play that, it moves on to the next option, whose type is specified as video/mp4. If neither of those can be played, the text "This browser does not support the HTML5 video element." is presented.

Specifications

Specification Comment
ETSI 3GPP Defines the 3GP container format
ISO/IEC 14496-3 (MPEG-4 Part 3 Audio) Defines MP4 audio including ADTS
FLAC Format The FLAC format specification
ISO/IEC 11172-1 (MPEG-1 Part 1 Systems) Defines the MPEG-1 container format
ISO/IEC 13818-1 (MPEG-2 Part 1 Systems) Defines the MPEG-2 container format
ISO/IEC 14496-14 (MPEG-4 Part 14: MP4 file format) Defines the MPEG-4 (MP4) version 2 container format
ISO/IEC 14496-1 (MPEG-4 Part 1 Systems) Defines the original MPEG-4 (MP4) container format
RFC 3533 Defines the Ogg container format
RFC 5334 Defines the Ogg media types and file extensions
QuickTime File Format Specification Defines the QuickTime movie (MOV) format
Multimedia Programming Interface and Data Specifications 1.0 The closest thing to an official WAVE specification
Resource Interchange File Format (used by WAV) Defines the RIFF format; WAVE files are a form of RIFF
WebM Container Guidelines Guide for adapting Matroska for WebM
Matroska Specifications The specification for the Matroska container format upon which WebM is based
WebM Byte Stream Format WebM byte stream format for use with Media Source Extensions

Browser compatibility

Container format name Audio Video
MIME type Extension(s) Browser support MIME type Extension(s) Browser support
3GP audio/3gpp .3gp Firefox video/3gpp .3gp Firefox
ADTS (Audio Data Transport Stream) audio/aac .aac Firefox
FLAC audio/flac .flac Firefox
MPEG-1 / MPEG-2 (MPG or MPEG) audio/mpeg .mpg
.mpeg
Firefox video/mpeg .mpg
.mpeg
Firefox
audio/mp3 .mp3 Firefox
MPEG-4 (MP4) audio/mp4 .mp4
.m4a
Firefox video/mp4 .mp4
.m4v
.m4p
Firefox
Ogg audio/ogg .oga
.ogg
Firefox video/ogg .ogv
.ogg
Firefox
QuickTime Movie (MOV) video/quicktime .mov  
WAV (Waveform Audiofile) audio/wav .wav Firefox
WebM audio/webm .webm Firefox video/webm .webm Firefox

 See also

Document Tags and Contributors

Contributors to this page: Sheppy, mdnwebdocs-bot
Last updated by: Sheppy,