What is MIME type "audio/webm"?
A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.
audio/webm is a MIME type for WebM audio streams. It packages audio data in an open-source container designed for efficient web streaming.It is built to work well in modern browsers and web apps. The format supports high-quality sound with low latency.
- Main use: Delivering streaming audio over the web.
- Other uses: Embedding audio in websites and mobile apps.
- Key features: Uses open codecs (like Opus and Vorbis) to keep file sizes small yet maintain sound quality.
Learn more details on the WebM Project website.
Associated file extensions
Usage Examples
HTTP Header
When serving content with this MIME type, set the Content-Type header:
Content-Type: audio/webm
HTML
In HTML, you can specify the MIME type in various elements:
<a href="file.dat" type="audio/webm">Download file</a>
Server-side (Node.js)
Setting the Content-Type header in Node.js:
const http = require('http');
http.createServer((req, res) => {
res.setHeader('Content-Type', 'audio/webm');
res.end('Content here');
}).listen(3000);
Associated file extensions
FAQs
What is the difference between the .webm and .weba file extensions?
The .weba extension is specifically used for WebM files that contain only audio streams, while .webm is the general extension for files containing video and/or audio. When serving audio-only content with the audio/webm MIME type, using the .weba extension helps users and players identify the content type immediately, though .webm is also technically valid.
Which web browsers support audio/webm?
Most modern browsers, including Google Chrome, Mozilla Firefox, Microsoft Edge, and Opera, have native support for audio/webm. Apple's Safari added support in later versions (iOS 15+ and macOS Monterey+), but for maximum compatibility with older devices, developers often provide an MP3 or AAC fallback alongside the WebM file.
How do I embed WebM audio in an HTML page?
You can embed the file using the HTML5 <audio> element with the type attribute set correctly. For example: <audio controls><source src="sound.weba" type="audio/webm"></audio>. It is best practice to include a fallback source (like audio/mpeg) inside the audio tag for older browsers that do not support WebM.
How do I configure Apache or Nginx to serve audio/webm correctly?
For Apache, add AddType audio/webm .weba to your .htaccess or configuration file. For Nginx, ensure your mime.types file includes the directive audio/webm weba;. Without these headers, browsers might attempt to download the file instead of streaming it.
What audio codecs are typically used inside an audio/webm container?
The audio/webm MIME type primarily utilizes the Opus or Vorbis audio codecs. Opus is generally preferred for newer applications because it offers superior audio quality at lower bitrates and lower latency compared to older codecs like MP3 or Vorbis.
Why should I use audio/webm over MP3?
WebM audio (specifically using the Opus codec) usually provides significantly higher audio quality per bit than MP3, resulting in smaller file sizes for the same quality. Additionally, audio/webm is an open, royalty-free format, making it ideal for the open web, whereas MP3 has a history of patent restrictions (though now expired).
What happens if I use video/webm for an audio-only file?
While it might technically play in some media players, using video/webm for audio-only files can cause issues in browsers, such as displaying a black video frame or empty player window. It is semantically correct to use audio/webm for audio-only streams to ensure the browser renders the standard audio controls rather than a video player interface.
General FAQ
What is a MIME type?
A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.
MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.
How do I find the MIME type for a file?
You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.
Why are multiple MIME types listed for one extension?
Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.