Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

The <audio> and <video> elements provide support for playing audio and video media without requiring plug-ins. Video codecs and audio codecs are used to handle video and audio, and different codecs offer different levels of compression and quality. A container format is used to store and transmit the coded video and audio (both together, the case of a video with a soundtrack). Many combinations of codecs and container formats exist, although only a handful of these are relevant on the Web.

Different browsers do not support the same media formats in their implementations of HTML5 video and audio, mainly because of patent issues. The area of media formats on the Web has greatly suffered from patent law in many countries  including the USA and EU countries (the notes on patents in this article is provided as-is and without any warranty.) This article discusses the different codec and container combinations relevant to the web, including support in browsers on both desktop and other device types.

To display a video using HTML5, which works in the newest versions of all major browsers, you can serve your video in both WebM format and MPEG H.264 AAC format, using the <source> element like this:

<video controls>
  <source src="somevideo.webm" type="video/webm">
  <source src="somevideo.mp4" type="video/mp4">
  I'm sorry; your browser doesn't support HTML5 video in WebM with VP8/VP9 or MP4 with H.264.
  <!-- You can embed a Flash player here, to play your mp4 video in older browsers -->
</video>

WebM

The WebM format is based on a restricted version of the Matroska container format. It always uses the VP8 or VP9 video codec and the Vorbis or Opus audio codec. WebM is natively supported in desktop and mobile Gecko (Firefox), Chrome and Opera, and support for the format can be added to Internet Explorer and Safari (but not on iOS) by installing an add-on. Native support for VP9 WebM is in progress for the Edge browser.

The WebM format, specifically the VP8 video codec, had been acccused of patent infringment by a group of companies answering a call by the MPEG LA for the formation of a patent pool, but MPEG LA has agreed to license those patents to Google under a "perpetual, transferable, royalty free license".  This means, effectively, that all known patents on the WebM format are licensed to everyone for free. 

Gecko recognizes the following MIME types as WebM files:

video/webm
A WebM media file containing video (and possibly audio as well).
audio/webm
A WebM media file containing only audio.

Ogg Theora Vorbis

The Ogg container format with the Theora video codec and the Vorbis audio codec is supported in desktop/mobile Gecko (Firefox), Chrome, and Opera, and support for the format can be added to Safari (but not on iOS) by installing an add-on. The format is not supported in Internet Explorer in any way.

WebM is generally preferred over Ogg Theora Vorbis when available, because it provides a better compression to quality ratio and is supported in more browsers. The Ogg format can however be used to support older browser versions (for example Firefox 3.5/3.6 don't support WebM, but do support Ogg.)

The patent situation of Theora is similar to that of WebM.

You can learn more about creating Ogg media by reading the Theora Cookbook.

Gecko recognizes the following MIME types as Ogg files:

audio/ogg
An Ogg file containing only audio.
video/ogg
An ogg file containing video (and possibly also audio).
application/ogg
An Ogg file with unspecified content. Using one of the other two MIME types is preferred, but you can use this if you don't know what the contents of the file are.

Ogg Opus

The Ogg container can also contain audio encoded using the Opus codec. Support for this is available in Gecko 15.0 (Firefox 15.0 / Thunderbird 15.0 / SeaMonkey 2.12) and later, on desktop and mobile browsers.

Ogg FLAC

The Ogg container can also contain audio encoded using the FLAC codec. Support for this is available in Gecko 51.0 (Firefox 51.0 / Thunderbird 51.0 / SeaMonkey 2.48) and later, on desktop only.

MP4 H.264 (AAC or MP3)

The MP4 container format with the H.264 video codec and the AAC audio codec is natively supported by desktop/mobile Internet Explorer, Safari and Chrome, but Chromium and Opera do not support the format. IE and Chrome also support the MP3 audio codec in the MP4 container, but Safari does not. Firefox/Firefox for Android/Firefox OS supports the format in some cases, but only when a third-party decoder is available, and the device hardware can handle the profile used to encode the MP4.

MP4s encoded with a high profile will not run on lower end hardware, such as low end phones.

The MPEG media formats are covered by patents, which are not freely licensed. Some of the necessary licenses can be bought from MPEG LA. Since H.264 is currently not a royalty free format, it is unfit for the open web platform, according to Mozilla [1, 2], Google [1, 2] and Opera. However, since royalty free formats are not supported by Internet Explorer and Safari, Mozilla has decided to support the format anyway, and Google never fulfilled their promise to remove support for it in Chrome.

MP3

The MP3 audio format (.mp3, audio/mpeg; distinct from the above MP3 audio in an MP4 container case) is supported in <audio> by Firefox/Firefox for Android/Firefox OS when the operating system provides an MP3 decoder, and by Internet Explorer, Chrome and Safari.

WAVE PCM

The WAVE container format, with the PCM audio codec (WAVE codec "1") is supported by desktop/mobile Gecko (Firefox) and Safari. Files in the WAVE container format typically end with the ".wav" extension.

See RFC 2361 for the WAVE codec registry.

Gecko recognizes the following MIME types as WAVE audio files:

  • audio/wave (preferred; does not work in Chrome)
  • audio/wav
  • audio/x-wav
  • audio/x-pn-wav

FLAC

The FLAC container format, with the FLAC audio codec (FLAC codec) is supported by desktop Gecko Firefox 51.0 (Firefox 51.0 / Thunderbird 51.0 / SeaMonkey 2.48). Files in the FLAC container format typically end with the ".flac" extension.

Gecko recognizes the following MIME types as FLAC audio files:

  • audio/flac (preferred)
  • audio/x-flac

Media Source Extensions (MSE)

Media Source Extensions is a W3C working draft that plans to extend HTMLMediaElement to allow JavaScript to generate media streams for playback. Allowing JavaScript to generate streams facilitates a variety of use cases like adaptive streaming and time shifting live streams. MSE support is restricted to MP4 and WebM containers but codec support varies depending on the underlying platform.

For example, you could implement MPEG-DASH using JavaScript while offloading the decoding to MSE.

Time shifting is the process of consuming a live stream some time after it happened.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 3.0 3.5 (1.9.1) 9.0 10.50 3.1
<audio>: PCM in WAVE (Yes) 3.5 (1.9.1) No support 10.50 3.1
<audio>: Vorbis in WebM (Yes) 4.0 (2.0) No support 10.60 3.1[1]
<audio>: Streaming Vorbis/Opus in WebM via MSE ? 36.0 (36.0)[2] ? ? ?
<audio>: Vorbis in Ogg (Yes) 3.5 (1.9.1) No support 10.50 No support
<audio>: MP3 (Yes)[4] (Yes)[5] 9.0 (Yes) 3.1
<audio>: MP3 in MP4 ? ? ? ? (Yes)
<audio>: AAC in MP4 (Yes)[6] (Yes)[7] 9.0 (Yes) 3.1
<audio>: Opus in Ogg 27.0 15.0 (15.0) ? ? ?
<audio>: FLAC No support 51 (51) No support No support No support
<audio>: FLAC in Ogg No support 51 (51) No support No support No support
<video>: VP8 and Vorbis in WebM 6.0 4.0 (2.0) 9.0[8] 10.60 3.1[9]
<video>: VP9 and Opus in WebM 29.0 28.0 (28.0)[36] ? (Yes) ?
<video>: Streaming WebM via MSE ? 42.0 (42.0)[35] ? ? ?
<video>: Theora and Vorbis in Ogg (Yes) 3.5 (1.9.1) No support 10.50 No support
<video>: H.264 and MP3 in MP4 (Yes)[4] (Yes)[10] 9.0 (Yes) (Yes)
<video>: H.264 and AAC in MP4 (Yes)[4] (Yes)[11] 9.0 (Yes) 3.1
any other format No support No support No support No support 3.1[12]
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile Chrome for Android
Basic support 2.3 24.0 1.0.1 10.0 11.0 (Yes)[13] 3.2 29.0
<audio>: PCM in WAVE ? 24.0 1.0.1 No support No support (Yes)[14] 3.2 ?
<audio>: Vorbis in WebM ? 24.0 1.0.1 No support 11.0 (Yes)[15] No support ?
<audio>: Streaming Vorbis in WebM via MSE ? ? ? ? ? ? ? ?
<audio>: Vorbis in Ogg ? 24.0 1.0.1 No support 11.0 (Yes)[16] No support ?
<audio>: MP3 ? (Yes)[17] (Yes)[18] 10.0 ? (Yes)[19] 3.2 ?
<audio>: MP3 in MP4 ? ? ? ? ? ? (Yes) ?
<audio>: AAC in MP4 ? (Yes)[20] (Yes)[21] 10.0 ? (Yes)[22] (Yes) ?
<audio>: Opus in Ogg No support 24.0 No support No support No support (Yes)[23] No support No support
<video>:  VP8 and Vorbis in WebM 2.3 24.0 1.0.1 No support 16.0 (Yes)[24] No support 29.0
<video>: VP9 and Opus in WebM ? ? ? ? ? ? ? ?
<video>: Streaming WebM via MSE ? 42.0 (42.0) ? ? ? ? ? ?
<video>: Theora and Vorbis in Ogg No support 24.0 1.0.1 No support No support (Yes)[25] No support No support
<video>:  H.264 and MP3 in MP4 (Yes)[26] 24.0[33] (Yes)[27] 10.0 16.0[28] (Yes)[29] (Yes) 29.0
<video>: H.264 and AAC in MP4 (Yes)[30] 24.0[34] (Yes)[31] 10.0 16.0[28] (Yes)[32] 3.2 29.0
any other format ? ? ? ? ? ? ? ?

[1] Must be installed separately.

[2] In Nightly/Dev Edition only.

[3] Only on platforms that don't support H.264.

[4] AAC is only supported in the MP4 container. Not in Chromium.

[5] To avoid patent issues, support for MP3 is not built directly into Firefox. Instead it relies on support from the OS. Firefox supports this format on the following platforms: Windows Vista+ since Firefox 22.0, Android since Firefox 20.0, Firefox OS since Firefox 15.0, Linux since Firefox 26.0 (relies on GStreamer codecs) and OS X 10.7 since Firefox 35.0.

[6] Main only. Not in Chromium. AAC is only supported in the MP4 container.

[7] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG 4 and AAC is not built directly into Firefox. Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4). Firefox supports these formats on the following platforms: Windows Vista+ since Firefox 22.0, Android since Firefox 20.0, Firefox OS since Firefox 15.0, Linux since Firefox 26.0 (relies on GStreamer codecs) and OS X 10.7 since Firefox 35.0.

[8] must be installed separately, e.g. WebM MF.

[9] Must be installed separately, e.g. Perian.

[10] To avoid patent issues, support for MPEG 4, H.264 and MP3 is not built directly into Firefox. Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4). Firefox supports these formats on the following platforms: Windows Vista+ since Firefox 22.0, Android since Firefox 20.0, Firefox OS since Firefox 15.0, Linux since Firefox 26.0 (relies on GStreamer codecs) and OS X 10.7 since Firefox 35.0.

[11] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG 4, H.264 and AAC is not built directly into Firefox. Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4). Firefox supports these formats on the following platforms: Windows Vista+ since Firefox 22.0, Android since Firefox 20.0, Firefox OS since Firefox 15.0, Linux since Firefox 26.0 (relies on GStreamer codecs) and OS X 10.7 since Firefox 35.0.

[12] Plays all formats available via QuickTime.

[13] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[14] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[15] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[16] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[17] To avoid patent issues, support for MP3 is not built directly into Firefox Mobile (Android). Instead it relies on support from the OS or hardware.

[18] To avoid patent issues, support for MP3 is not built directly into Firefox OS. Instead it relies on support from the OS or hardware.

[19] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[20] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG 4 and AAC is not built directly into Firefox Mobile (Android). Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

[21] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG 4 and AAC is not built directly into Firefox OS. Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

[22] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats. AAC is only supported in the MP4 container.

[23] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[24] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[25] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[26] To get the default Android browser to play H.264 video, you need to jump through some hoops, as explained by Peter Gasston.

[27] In Firefox OS 1.0.1, when detecting <video> support for different formats, HTMLMediaElement.prototype.canPlayType incorrectly reports true for h.264 video whereas in actual fact h.264 is not supported. In Firefox OS 1.1 this problem has been fixed.
To avoid patent issues, support for MPEG 4, H.264 and MP3 is not built directly into Firefox Mobile (Android) and Firefox OS. Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

[28] Partial since 11.0. AAC is only supported in the MP4 container.

[29] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats.

[30] AAC is only supported in the MP4 container. To get the default Android browser to play H.264 video, you need to jump through some hoops, as explained by Peter Gasston.

[31] In Firefox OS 1.0.1, when detecting <video> support for different formats, HTMLMediaElement.prototype.canPlayType incorrectly reports true for h.264 video whereas in actual fact h.264 is not supported. In Firefox OS 1.1 this problem has been fixed. AAC is only supported in the MP4 container.
To avoid patent issues, support for MPEG 4, H.264 and ACC is not built directly into Firefox OS. Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

[32] Opera Mini itself doesn't support any video or audio, but any video or audio is passed to the device to play if it has support for that format. Opera Mobile also does this with unsupported formats. AAC is only supported in the MP4 container.

[33] To avoid patent issues, support for MPEG 4, H.264 and MP3 is not built directly into Firefox Mobile (Android). Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

[34] To avoid patent issues, support for MPEG 4, H.264 and ACC is not built directly into Firefox Mobile (Android). Instead it relies on support from the OS or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

[35] VP8/VP9 video codecs are only available in MSE when H.264 hardware decoders are not available. Checking for availability via MediaSource.isTypeSupported() is recommended.

[36] Starting in Firefox 46, when attempting to initiate a WebRTC call using RTCPeerConnection.createOffer() uses VP9 by default; in the past, VP8 was the default video format.

See also