·7 min read
WAV vs MP3 vs OGG for Web Audio
Three common audio formats for the web, each with clear use cases. Short answer: MP3 for maximum compatibility, AAC for Apple ecosystem, OGG Vorbis for royalty-free, WAV for editing. Never serve WAV to end users in production.
Format comparison
Same 3-minute audio clip:
- WAV (uncompressed, 44.1kHz, 16-bit) — ~30 MB
- MP3 128kbps — ~3 MB (10x smaller, near-CD quality)
- MP3 320kbps — ~7 MB (audiophile, transparent to most ears)
- OGG Vorbis q5 — ~2.5 MB (better quality than MP3 at same size)
- AAC 128kbps — ~3 MB (better than MP3 at same bitrate)
When to use WAV
- Editing and production (DAW, audio editing software)
- Archival masters
- Very short sound effects where size doesn't matter
Never serve WAV to end users over HTTP. A 3-minute WAV is 30MB; the same MP3 is 3MB with no perceptible difference.
When to use MP3
- Maximum browser and device compatibility (everything plays MP3)
- Podcasts, audiobooks, music downloads
- Legacy systems, older Android versions
128 kbps is the sweet spot. 320 kbps is audiophile territory.
When to use OGG Vorbis
- Royalty-free distribution (MP3 patents technically expired, but habits linger)
- Games (most game engines prefer OGG for sound effects and music loops)
- When you control the player
Safari historically didn't support OGG natively. That's now resolved in macOS 14+ and iOS 17+ but older devices still fail.
When to use AAC
- Apple ecosystem (iTunes, Apple Podcasts, YouTube audio)
- Inside MP4 containers for streaming video
- Better quality than MP3 at the same bitrate
Multi-format HTML5 audio
<audio controls>
<source src="audio.aac" type="audio/aac" />
<source src="audio.ogg" type="audio/ogg" />
<source src="audio.mp3" type="audio/mpeg" />
Your browser doesn't support audio.
</audio>
Browsers pick the first format they can play. AAC first for Apple, OGG for Firefox, MP3 as universal fallback.
Conversion with ffmpeg
# WAV → MP3 128kbps
ffmpeg -i input.wav -b:a 128k output.mp3
# WAV → OGG Vorbis q5
ffmpeg -i input.wav -c:a libvorbis -q:a 5 output.ogg
# WAV → AAC 128kbps
ffmpeg -i input.wav -c:a aac -b:a 128k output.m4a
Streaming considerations
- Set
Content-Lengthfor<audio preload="metadata">to show duration - Support HTTP range requests for seek
- Cache immutably with hashed filenames:
audio-a1b2c3.mp3
Related
For server-side handling, see audio upload validation and transcoding.