Media Formats
The HTML5 specification defined a standard user interface for playing audio and video files in a browser. One thing it did not do was define what format the audio and video files should use. Legally, it could not. The compression and decompression algorithms (codecs) used for media files are copyrighted or patented. Only the OGG format is open-source and can be freely used.
So the companies, organizations, owners of the codec copyrights/patents, and browser creators needed to get together and figure out a solution. After many years of negotiation, the group settled on three audio and three video file formats. The following tables list the browser support for each audio and video file format. One thing to note is that the Microsoft Edge browser has two entries in the table. When Microsoft released Edge version 79, it scrapped its proprietary browser engine and switched to Chromium. So depending on the version of Edge, support for media file formats is different.
Audio file formats
Of the seven common audio file formats, only three are supported in most browsers: MP3, WAV, and OGG. A browser may support other file formats, but if it is HTML5 compliant, it will use at least one of the three formats.
Browser | MP3 | WAV | OGG |
---|---|---|---|
Chrome | Yes | Yes | Yes |
Firefox | Yes | Yes | Yes |
IE10+/Edge | Yes | No | No |
Opera | Yes | Yes | Yes |
Safari | Yes | Yes | No |
Video file formats
Of the eight common video file formats, the three supported are MP4, WebM, and OGG. If a browser is HTML5 compliant, it will use at least one of the three formats.
Browser | MP4 | WebM | OGG |
---|---|---|---|
Chrome | Yes | Yes | Yes |
Firefox | Yes | Yes | Yes |
IE10+/Edge | Yes | No | No |
Edge v79+ | Yes | Yes | Yes |
Opera | Yes | Yes | Yes |
Safari | Yes | No | No |
Note: The WebM file format is also used for audio files. Browsers supporting WebM containing only audio will display an audio player, not a video player.
MIME types
When the server sends a file to the browser, part of the data is the “Content-Type,” which informs the browser what it should expect the data to contain. This data is the MIME (Multipurpose Internet Mail Extensions) type. You must specify a MIME type if you use the <source> in either the <audio> or <video> tags. Write MIME-type rules in the form:
type="MIME-type/subtype"
Where “MIME-type” is either “audio” or “video,” and the “subtype” specifies the file’s coding format. The following table lists the subtypes for each media file format mentioned above.
MP3 | WAV | OGG (audio) | MP4 | WebM | OGG (video) |
---|---|---|---|---|---|
audio/mp3 | audio/wav | >audio/ogg | video/mp4 | video/webm | video/ogg |
File conversion
You will need to convert the file if you have an audio or video file you want to use on your web page but it is not in one of the specified file formats. If you have a WAV file, you may also want to convert it to one of the other acceptable formats. A WAV file is quite large compared to other formats and will impact page load time.
There are several methods to do this:
(1) If you have the VLC Media Player (it’s free). It has a built-in utility that will convert a media file to another format. Use the keyboard shortcut CTRL+R, or find the option under the Media menu.
(2) Several free online sites that will convert your media file. Search for “convert to mp3” or “convert to mp4” to get a list. Be sure to read the site’s limitations. For example, some are free for a limited number of conversions, limit the uploaded file size, or will only convert a limited number of minutes of the media file.
(3) Download and install a desktop app. The Microsoft store has a free app called “Media Converter.” The app’s primary purpose is to strip the audio track from a video file, but it is capable of converting and resizing media files. I have never used this app, so I cannot comment on how good or bad it is.
My go-to desktop app is the Miro Video Converter. While it bills itself as a video converter, I have not had problems converting audio files.
Linux OS
The Linux OS mainly hosts websites and provides internet services, but it comprises about 2% of desktop users. The MP4 compression format is proprietary and requires a license. Linux is open-source software, so MP4 support is rarely found on Linux systems. To target Linux users, you should use either the WebM or OGG file formats.