Media formats for HTML audio and movie – HTML, MDN
Media formats for HTML audio and movie
The element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the <source> element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream."> <audio> and element to embed movie content in a document."> <movie> elements provide support for playing audio and movie without plug-ins. The format of a media file consists of a container holding one or more flows of data, encoded using a compression format called a codec. A container is identifiable by its file extension. The rivulets within a container are of numerous types that can include movie, audio, data, or captions. A single container (i.e. media file) can hold numerous rivulets of the same type. Within the audio and movie flows are are the codecs. A codec, brief for "coder-decoder", is an algorithm for compressing data within a file. Each container type has only specific codecs that it supports.
It’s significant to understand why different media formats are needed for the web. For various reasons mostly outside the scope of this article, different browsers support different media formats. Also, 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 are provided as-is and without any warranty.) This article discusses the formats most relevant to the web, including support in browsers on both mobile and desktop.
Displaying Media
Here’s a brief review of how media elements are referenced in HTML. For more details see the articles for each element.
File Formats
Listed below are a number (tho’ not all) of file formats supported by HTML media elements. To learn which browsers support which formats, see the Browser Compatibility section at the bottom of this page.
The WebM format is based on a restricted version of the Matroska container format. It always uses the VP8 or VP9 movie codec and the Vorbis or Opus audio codec.
The WebM format, specifically the VP8 movie codec, had been accused 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:
movie/webm A WebM media file containing movie (and possibly audio as well). audio/webm A WebM media file containing only audio.
Ogg Theora Vorbis
The Ogg container format with the Theora movie 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 Three.Five/Three.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. movie/ogg An ogg file containing movie (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 Two.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 Two.48) and later, on desktop only.
MP4 H.264 (AAC or MP3)
The MP4 container format with the H.264 movie 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 treat 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 loosely licensed. Some of the necessary licenses can be bought from MPEG LA. Since H.264 is presently not a royalty free format, it is unfit for the open web platform, according to Mozilla [1, Two], Google [1, Two] and Opera. However, since royalty free formats are not supported by Internet Explorer and Safari, Mozilla has determined to support the format anyway, and Google never fulfilled their promise to eliminate support for it in Chrome.
MP4 FLAC
Kicking off in Firefox 51, you can play MP4 files using the FLAC codec, both with and without MediaSource Extensions and DRM support.
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.
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
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 Two.48). Files in the FLAC container format typically end with the ".flac" extension.
Gecko recognizes the following MIME types as FLAC audio files:
Browser compatibility
[1] Must be installed separately.
[Two] In Nightly/Dev Edition only.
[Trio] Only on platforms that support H.264.
[Four] AAC is only supported in the MP4 container. Not in Chromium.
[Five] 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 Ten.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 four 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 movie, 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 Ten.7 since Firefox 35.0.
[9] Must be installed separately, e.g. Perian.
[Ten] To avoid patent issues, support for MPEG Four, 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 movie, 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 Ten.7 since Firefox 35.0.
[11] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG Four, 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 movie, 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 Ten.7 since Firefox 35.0.
[12] Plays all formats available via QuickTime.
[13] Opera Mini itself doesn’t support any movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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.
[Legitimate] To avoid patent issues, support for MP3 is not built directly into Firefox OS. Instead it relies on support from the OS or hardware.
[Nineteen] Opera Mini itself doesn’t support any movie or audio, but any movie 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 four 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 movie, in the case of MP4).
[21] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG four 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 movie, in the case of MP4).
[22] Opera Mini itself doesn’t support any movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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 movie, you need to leap through some hoops, as explained by Peter Gasston.
[27] In Firefox OS 1.0.1, when detecting <movie> support for different formats, HTMLMediaElement.prototype.canPlayType incorrectly reports true for h.264 movie whereas in actual fact h.264 is not supported. In Firefox OS 1.1 this problem has been stationary.
To avoid patent issues, support for MPEG Four, 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 movie, 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 movie or audio, but any movie 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 movie, you need to hop through some hoops, as explained by Peter Gasston.
[31] In Firefox OS 1.0.1, when detecting <movie> support for different formats, HTMLMediaElement.prototype.canPlayType incorrectly reports true for h.264 movie whereas in actual fact h.264 is not supported. In Firefox OS 1.1 this problem has been immovable. AAC is only supported in the MP4 container.
To avoid patent issues, support for MPEG Four, 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 movie, in the case of MP4).
[32] Opera Mini itself doesn’t support any movie or audio, but any movie 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 Four, 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 movie, in the case of MP4).
[34] To avoid patent issues, support for MPEG Four, 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 movie, in the case of MP4).
Media formats for HTML audio and movie – HTML, MDN
Media formats for HTML audio and movie
The element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the <source> element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream."> <audio> and element to embed movie content in a document."> <movie> elements provide support for playing audio and movie without plug-ins. The format of a media file consists of a container holding one or more flows of data, encoded using a compression format called a codec. A container is identifiable by its file extension. The flows within a container are of numerous types that can include movie, audio, data, or captions. A single container (i.e. media file) can hold numerous flows of the same type. Within the audio and movie rivulets are are the codecs. A codec, brief for "coder-decoder", is an algorithm for compressing data within a file. Each container type has only specific codecs that it supports.
It’s significant to understand why different media formats are needed for the web. For various reasons mostly outside the scope of this article, different browsers support different media formats. Also, 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 are provided as-is and without any warranty.) This article discusses the formats most relevant to the web, including support in browsers on both mobile and desktop.
Displaying Media
Here’s a brief review of how media elements are referenced in HTML. For more details see the articles for each element.
File Formats
Listed below are a number (tho’ not all) of file formats supported by HTML media elements. To learn which browsers support which formats, see the Browser Compatibility section at the bottom of this page.
The WebM format is based on a restricted version of the Matroska container format. It always uses the VP8 or VP9 movie codec and the Vorbis or Opus audio codec.
The WebM format, specifically the VP8 movie codec, had been accused 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:
movie/webm A WebM media file containing movie (and possibly audio as well). audio/webm A WebM media file containing only audio.
Ogg Theora Vorbis
The Ogg container format with the Theora movie 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 Three.Five/Three.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. movie/ogg An ogg file containing movie (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 Two.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 Two.48) and later, on desktop only.
MP4 H.264 (AAC or MP3)
The MP4 container format with the H.264 movie 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 treat 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 loosely licensed. Some of the necessary licenses can be bought from MPEG LA. Since H.264 is presently not a royalty free format, it is unfit for the open web platform, according to Mozilla [1, Two], Google [1, Two] and Opera. However, since royalty free formats are not supported by Internet Explorer and Safari, Mozilla has determined to support the format anyway, and Google never fulfilled their promise to liquidate support for it in Chrome.
MP4 FLAC
Beginning in Firefox 51, you can play MP4 files using the FLAC codec, both with and without MediaSource Extensions and DRM support.
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.
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
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 Two.48). Files in the FLAC container format typically end with the ".flac" extension.
Gecko recognizes the following MIME types as FLAC audio files:
Browser compatibility
[1] Must be installed separately.
[Two] In Nightly/Dev Edition only.
[Three] Only on platforms that support H.264.
[Four] AAC is only supported in the MP4 container. Not in Chromium.
[Five] 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 Ten.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 four 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 movie, 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 Ten.7 since Firefox 35.0.
[9] Must be installed separately, e.g. Perian.
[Ten] To avoid patent issues, support for MPEG Four, 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 movie, 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 Ten.7 since Firefox 35.0.
[11] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG Four, 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 movie, 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 Ten.7 since Firefox 35.0.
[12] Plays all formats available via QuickTime.
[13] Opera Mini itself doesn’t support any movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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.
[Legal] To avoid patent issues, support for MP3 is not built directly into Firefox OS. Instead it relies on support from the OS or hardware.
[Nineteen] Opera Mini itself doesn’t support any movie or audio, but any movie 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 four 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 movie, in the case of MP4).
[21] AAC is only supported in the MP4 container. To avoid patent issues, support for MPEG four 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 movie, in the case of MP4).
[22] Opera Mini itself doesn’t support any movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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 movie or audio, but any movie 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 movie, you need to hop through some hoops, as explained by Peter Gasston.
[27] In Firefox OS 1.0.1, when detecting <movie> support for different formats, HTMLMediaElement.prototype.canPlayType incorrectly reports true for h.264 movie whereas in actual fact h.264 is not supported. In Firefox OS 1.1 this problem has been immobile.
To avoid patent issues, support for MPEG Four, 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 movie, 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 movie or audio, but any movie 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 movie, you need to leap through some hoops, as explained by Peter Gasston.
[31] In Firefox OS 1.0.1, when detecting <movie> support for different formats, HTMLMediaElement.prototype.canPlayType incorrectly reports true for h.264 movie whereas in actual fact h.264 is not supported. In Firefox OS 1.1 this problem has been immobile. AAC is only supported in the MP4 container.
To avoid patent issues, support for MPEG Four, 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 movie, in the case of MP4).
[32] Opera Mini itself doesn’t support any movie or audio, but any movie 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 Four, 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 movie, in the case of MP4).
[34] To avoid patent issues, support for MPEG Four, 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 movie, in the case of MP4).