AudioUtils

Opus Audio for Web Developers: A Practical Guide

Opus cuts file sizes in half vs MP3 with better quality. MIME types, browser support, Web Audio API, WebRTC, MediaRecorder, and web delivery practices.

Opus is the best audio codec for the web that most web developers are still not using. It is natively supported in every major browser, delivers better quality than MP3 at half the bitrate, has extremely low latency, and is completely royalty-free. This guide covers everything you need to ship Opus audio in a web application.

Browser Support Overview

Opus has broad modern browser support. As of 2026:

  • Chrome (desktop and Android): Full support since Chrome 25
  • Firefox (desktop and Android): Full support since Firefox 15
  • Edge: Full support
  • Opera: Full support
  • Safari (desktop and iOS): Full support since Safari 11 (2017)

Opus support is now universal among maintained browser versions. You can serve Opus without providing a fallback in applications that do not need to support outdated browsers.

For maximum safety in applications that might serve older devices, provide an MP3 fallback using the HTML5 `

MIME Types for Opus

Opus audio uses the OGG container or the WebM container. The correct MIME types are:

OGG container: ``` audio/ogg; codecs=opus ```

WebM container: ``` audio/webm; codecs=opus ```

Using the wrong MIME type can cause browsers to reject the file or treat it incorrectly. When serving Opus from a web server, configure your server to send the correct Content-Type header.

For nginx: ``` types { audio/ogg ogg opus; audio/webm webm; } ```

For Apache, add to `.htaccess` or server config: ``` AddType audio/ogg .ogg .opus ```

HTML5 Audio Element with Opus

The simplest way to serve Opus with a fallback:

```html

Your browser does not support audio playback.

```

Browsers try each `` in order and use the first one they support. Because Opus support is now universal in maintained browsers, the MP3 fallback will rarely be triggered — but it is good defensive practice.

File Size Advantage: The Real Numbers

This is the core reason to adopt Opus. A 4-minute stereo music track:

| Format | Bitrate | Approximate size | |--------|---------|------------------| | MP3 | 192 kbps | 5.5 MB | | AAC | 192 kbps | 5.5 MB | | Opus | 128 kbps | 3.8 MB | | Opus | 96 kbps | 2.8 MB |

Opus at 96 kbps delivers quality comparable to MP3 at 192 kbps in listening tests. That is approximately half the file size for equivalent perceived quality.

Bandwidth savings for a podcast site. Consider a site with 10,000 monthly listeners, each streaming a 45-minute episode:

  • MP3 at 128 kbps: 45 min x 128 kbps x 10,000 = 4.32 TB/month
  • Opus at 64 kbps: 45 min x 64 kbps x 10,000 = 2.16 TB/month

Halving your bandwidth bill is not a minor optimization.

Web Audio API and Opus

The Web Audio API decodes Opus natively via `decodeAudioData`:

```javascript const response = await fetch('audio.opus'); const arrayBuffer = await response.arrayBuffer(); const audioContext = new AudioContext(); const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);

const source = audioContext.createBufferSource(); source.buffer = audioBuffer; source.connect(audioContext.destination); source.start(); ```

This works in all browsers that support Opus. No special configuration is required. The browser's native Opus decoder handles the format transparently.

WebRTC and Opus

Opus is the mandatory audio codec for WebRTC as specified in RFC 7874. Every WebRTC implementation — video calls, voice chat, peer-to-peer audio — uses Opus internally.

Discord, Google Meet, and most browser-based communication tools transmit audio as Opus at 32–128 kbps depending on bandwidth conditions. The low latency of Opus (approximately 5 ms algorithmic delay) is what makes real-time communication viable.

As a web developer building any real-time audio application, you do not need to configure this — WebRTC handles codec negotiation automatically. But knowing that Opus is the underlying technology is useful context.

MediaRecorder API and Opus Output

When you use the MediaRecorder API to record audio in the browser, you can request Opus output explicitly:

```javascript const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); const mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/webm; codecs=opus' });

const chunks = []; mediaRecorder.ondataavailable = (e) => chunks.push(e.data); mediaRecorder.onstop = () => { const blob = new Blob(chunks, { type: 'audio/webm; codecs=opus' }); const url = URL.createObjectURL(blob); // Use the URL for playback or upload };

mediaRecorder.start(); ```

Chrome and Firefox both support `audio/webm; codecs=opus` as a MediaRecorder mimeType. Safari uses different defaults — check support with `MediaRecorder.isTypeSupported()` before relying on a specific mimeType.

Converting Existing Audio to Opus for Web Delivery

If you have a library of MP3 or WAV files and want to serve them as Opus, AudioUtils handles the conversion in the browser:

Both conversions run locally in WebAssembly. You get the .opus output file ready to drop into your web server's static assets directory.

For batch conversion of large audio libraries, consider processing files through AudioUtils and uploading to your CDN. Serving Opus as the primary format with MP3 fallback is a straightforward one-time migration that pays dividends in bandwidth savings and load times for the lifetime of your application.

When Opus Is Not the Right Choice

  • Podcast RSS feeds: Many podcast apps and aggregators expect MP3 or AAC. Changing your enclosure format requires checking compatibility across every app your listeners use. MP3 remains safer for podcast distribution.
  • Legacy embedded players: If your application needs to work in very old browsers or OS-level players (Windows Media Player on old Windows installs), MP3 is more universally supported.
  • Music downloads: Users downloading files to their local library may find that their music software or device handles MP3 better. Convert Opus to MP3 when distributing for general download.

Summary

Opus is technically superior to MP3 and AAC for web delivery in almost every measurable way — quality, file size, latency, and licensing. Browser support is universal. The only remaining reason not to use it is legacy compatibility for specific edge cases. Adopt Opus as your default web audio format, provide MP3 fallbacks where needed, and use AudioUtils to convert your existing audio assets for the transition.

More to Read

Best Audio Format for Music ProductionBest Audio Format for PodcastsBest Audio Format for GamingBest Audio Format for Music StreamingBest Audio Format for Archiving MusicWhen Should You Convert MP3 to WAV?Convert WAV to MP3 for Sharing and EmailHow to Convert MP3 to OGG for Unity Game DevelopmentBest Audio Format for Discord in 2026Best Audio Format for Video EditingPrivacy-First Audio Conversion: Why Browser-Based MattersBest Audio Format for Zoom RecordingsBest Audio Format to Use in AudacityBest Audio Format for Voice RecordingGarageBand Audio Formats: What to Use and WhyAudio Sample Rates: 44.1, 48, 96 kHz ExplainedBest Audio Format for iMovie: Import and Export GuideAdobe Premiere Pro Audio Format GuideLogic Pro Audio Guide: Best Import & Export SettingsOBS Studio Audio Format and Settings GuideTwitch Audio Requirements: Format, Bitrate & QualitySpotify Audio Format: What You Need to KnowYouTube Audio Requirements: Quality, Format & LUFSTikTok Audio Requirements: Format, Bitrate, and QualityBest Audio Format for Ringtones: iPhone and AndroidBest Audio Format for Car USB: MP3, FLAC, or WAV?Best Audio Format for AudiobooksAudio Formats for Podcast Apps: Spotify, Apple, and MoreBest Audio Format for Discord: Opus, MP3, and File LimitsBest Audio Format for TikTok: Specs and Upload TipsBest Audio Format for Instagram Reels and StoriesAudio File Too Large? How to Reduce Audio File SizeAudio Formats for Zoom: Recordings, Uploads, and SharingBest Audio Format for YouTube Uploads in 2026Best Audio Format for Audacity: Import, Edit, and ExportBest Audio Format for Premiere Pro: Timelines & ExportWhy Is My Audio File So Large? How to Reduce ItMP3 File Corrupted: How to Diagnose and Fix ItAudio Format for Spotify: Upload Specs & What HappensBest Free Audio Converter: Browser-Based vs DesktopWhat Is MP3? The Format ExplainedWhat Is WAV? Everything You Need to KnowWhat Is FLAC? The Lossless Audio FormatWhat Is OGG? The Open Container Format ExplainedWhat Is M4A? Apple's Audio Format ExplainedWhat Is AAC? Advanced Audio Coding ExplainedWhat Is AIFF? Apple's Lossless Audio FormatWhat Is WMA? Windows Media Audio ExplainedAudio Bitrate Explained: What It Means for QualitySample Rate Explained: 44.1kHz vs 48kHz vs 96kHzMP3 vs WAV: Which Format Should You Use?MP3 vs FLAC: Lossy vs Lossless ComparedMP3 vs AAC: Which Codec Sounds Better?MP3 vs OGG (Vorbis): The Complete ComparisonFLAC vs WAV: Lossless Formats ComparedM4A vs MP3: Which Should You Choose?Lossless vs Lossy Audio: The Complete GuideAudio Formats Explained: The Complete GuideHow to Convert Audio Files: Complete GuideHow to Reduce Audio File Size Without Losing QualityHow to Convert iPhone Voice Memo to MP3 FreeHow Audio Compression WorksBest Audio Format for WebsitesHow to Batch Convert Audio FilesHow to Extract Audio from Video FilesDoes Converting MP3 to WAV Improve Quality?Why WAV Files Are So Large (And What to Do About It)How to Convert MP3 to WAV for Music ProductionHow to Convert MP3 to WAV Without Losing QualityMP3 vs WAV for Audio Editing in a DAWHow to Convert MP3 to WAV on Mac and WindowsHow to Convert WAV to MP3 Without Losing QualityWAV File Too Large? Convert to MP3How to Convert iPhone Voice Memo to MP3 FreeHow to Play M4A Files on Android (Convert to MP3)M4A vs MP3: Which Has Better Quality and Smaller Size?What Is M4A? The iPhone Audio Format ExplainedOGG vs MP3 for Web Audio: Which Should You Use?WAV vs AIFF: Which Uncompressed Format?AAC vs OGG: Which Lossy Codec Wins?M4A vs AAC: What's the Difference?How to Convert FLAC to MP3 Without Losing QualityBest Bitrate for FLAC to MP3 ConversionConvert AAC to MP3: Best Quality SettingsHow to Extract Audio from MP4 FilesConvert iPhone MOV Video to MP3How to Convert WAV to MP3 (The Complete Guide)How to Convert MOV to MP3 (iPhone & QuickTime)How to Convert MP3 to WAV for Editing and DAWsHow to Convert YouTube to MP3 Legally (3 Ways)Best MP3 to WAV Settings for Editing and DAWsBest WAV to MP3 Bitrate for Music, Podcasts, and VoiceMOV to MP3 on Mac: Fastest Ways ComparedHow to Convert M4A to MP3 on iPhone Without a ComputerHow to Convert FLAC to MP3 on MacHow to Convert FLAC to MP3 on WindowsHow to Convert OGG to MP3 on MacHow to Convert MP4 to MP3 on MacHow to Convert MP4 to MP3 on iPhoneHow to Convert MP4 to MP3 on AndroidHow to Convert WMA to MP3 on MacHow to Convert AIFF to MP3 on MacHow to Convert MOV to MP3 on WindowsMP3 vs WMA: Which Format Should You Choose?AAC vs FLAC: Lossy or Lossless — Which to Choose?Audio File Size Comparison: MP3, WAV, FLAC, OGG, AACM4A to WAV: How to Convert and WhyHow to Convert FLAC to OGG VorbisHow to Convert AAC to WAV for EditingHow to Convert WMA to MP3 on WindowsHow to Convert AIFF to MP3 on WindowsHow to Convert OGG to MP3 on WindowsHow to Convert FLAC to MP3 on iPhoneHow to Convert AAC to MP3 on MacHow to Convert M4A to MP3 on Mac: 3 Easy MethodsHow to Convert Audio Files with AudacityHow to Convert Audio Files with VLCAudacity vs AudioUtils: Which Should You Use?AIFF vs FLAC: Which Lossless Format Is Better?WMA vs MP3: Which Sounds Better?OGG vs AAC: Which Audio Codec Is Better?M4A vs OGG: Which Lossy Audio Codec to UseWhat Is Vorbis? The Open Audio Codec ExplainedWhat Is ALAC? Apple Lossless Audio ExplainediTunes and Apple Music Audio Formats ExplainedFLAC to AAC: Bitrate Guide and Practical StepsOGG to AAC: Cross-Platform Audio Migration GuideWMA to OGG: Escape the Windows Media EcosystemWMA to FLAC: Lossless Archiving of Your Old WMA LibraryFLAC to Opus: Web Streaming Optimization GuideAIFF to M4A: Apple Production Workflow GuideWAV to AIFF: Windows to Mac Audio WorkflowWhat Is HLS Audio? HTTP Live Streaming ExplainedAIFF vs. AIF: What Is the Difference?Android Audio Formats: Native Support and Best PracticesiPhone Audio Formats: What iOS Supports & Doesn'tHow to Convert AAC to MP3 on iPhoneHow to Convert FLAC to MP3 on AndroidHow to Convert OGG to MP3 on AndroidHow to Convert WAV to MP3 on iPhoneHow to Convert AIFF to MP3 on iPhoneHow to Convert M4A to MP3 on WindowsOpus to MP3: Complete Conversion GuideMP3 Bitrate Guide: 128 to 320 kbps ExplainedFLAC vs Opus: When to Use Each Audio CodecWAV vs MP3: The Honest Quality ComparisonAAC vs. MP3 for Streaming: Which Is Better?Convert Audio on Linux: Command Line and Browser OptionsFFmpeg vs. AudioUtils: When to Use EachHow to Convert Audio Without Installing SoftwareAudio Bitrate vs. Sample Rate: What's the Difference?How to Convert WMA to MP3 on Mac (Step-by-Step Guide)Audio Transcoding vs. Converting: What Is the Difference?OGG to FLAC: What to Expect from the ConversionAAC to FLAC: Convert and What to ExpectOpus to WAV: How to Convert and Why You Might Need ToWAV to Opus: The Web Developer's Audio GuideOGG vs FLAC: Which Should You Use?Opus vs AAC: Which Codec Is Better?WAV vs FLAC for Archiving: Which Is Best?M4A vs FLAC: Apple AAC vs Lossless Quality ComparedBest Audio Format for Speech-to-Text TranscriptionBest Audio Format for WhatsApp Voice MessagesAudio Formats Windows Media Player Plays NativelyAudio Formats VLC Supports and Its Conversion FeaturesAudio Formats Foobar2000 SupportsAudio Formats Plex Media Server SupportsKodi Audio Format: What Works & What Needs ConversionAudio Formats for PS4 and PS5 USB PlaybackAudio Formats for Xbox USB PlaybackAudio on Nintendo Switch: Limitations and WorkaroundsMP3 vs AAC for AirPods: Does the Codec Matter?How to Play FLAC on iPhone (iOS 11 and Later)How to Play FLAC on Android NativelyWAV to FLAC: Converting Without Any Quality LossAIFF to WAV: macOS to Windows Audio WorkflowM4A to OGG: Converting Apple Audio to Open-SourceOpus Bitrate Guide: 32, 64, 96, 128, 192 kbps ExplainedAudio Normalization: Peak vs Loudness — When to Use EachAudio Quality Settings: Bitrate, Sample Rate, Bit DepthReduce Audio File Size Without Losing QualityAudio Format Support on Raspberry Pi with mpd and mopidyBest Audio Format in 2025: The Definitive GuideIs yt-dlp Legal? What You Need to KnowLegal Ways to Download Music for Offline ListeningCreative Commons Music for Content Creators: Full GuideWMA to MP3: What to Expect and How to ConvertAIFF to MP3: GarageBand Exports and Quality SettingsMP3 vs. WAV for Podcasting: Which Format to UseAudio Sample Rate Explained: 44.1 vs 48 vs 96kHzHow to Convert Audio on Mac: GarageBand & QuickTimeHow to Convert Audio on iPhone: Files App & BrowserHow to Batch Convert Audio Files: FFmpeg & BrowserFLAC vs. ALAC: Lossless Audio Format ComparisonWhat Is VBR vs CBR? Bit Allocation in Audio EncodingExtract Audio from MP4 Without Software (Browser Method)Container vs Codec: The Most Confusing Thing in AudioPCM Audio Explained: Why WAV Files Are So LargeVBR vs CBR for MP3: When Each Mode Is the Right ChoiceMP3 128 kbps vs 320 kbps: Does the Difference Matter?FLAC vs WAV for Music Production: The Practical AnswerM4A vs MP3 for iPhone: Which Format to Use and WhenOGG Vorbis vs MP3: Quality, Compatibility & When OGG WinsHow to Convert iPhone Voice Memo to MP3 (Free, No App)How to Convert Zoom Recording to MP3 (M4A or MP4 Export)How to Convert Google Meet Recording to MP3Audio Bitrate Guide: Right Settings for Every Use CaseLossless Audio: Is It Worth It? The Honest AnswerHow to Extract Audio from a Zoom Webinar RecordingAudio Compression Explained: File Size vs Dynamic RangeHow to Compress Audio in Audacity: Size & DynamicsFFmpeg Compress Audio: MP3, FLAC, Opus & AAC One-LinersCompress MP3 Without Losing Quality: What's PossibleHow to Make a Ringtone From an MP3 (iPhone & Android)How to Trim an MP3 Without Losing QualityHow to Cut Audio in Audacity (2026 Step-by-Step)How to Merge Audio Files: Three Real MethodsHow to Remove Vocals From a Song (Honest 2026 Guide)How to Record Audio on Mac: 2026 GuideHow to Record Audio on Windows: 2026 GuideHow to Record Audio on iPhone: 2026 GuideID3 Tags Explained: MP3 Metadata StandardHow to Edit MP3 Metadata: Tools & WorkflowsHow to Find BPM of a Song: 5 MethodsHow to Split Audio Files: 3 Methods That Work