Choosing the right audio and video format affects file size, quality, and browser compatibility. The web media landscape has evolved significantly, with modern codecs offering dramatic improvements over older formats. Here's how to choose.
Video Formats
MP4 (H.264 + AAC)
The universal video format. H.264 video with AAC audio in an MP4 container is supported by every browser, every device, and every video player. If you're not sure what to use, use this.
- Best for: Maximum compatibility, simple websites, fallback format
- File size: Medium. H.264 is mature but less efficient than newer codecs
- Browser support: 100% (all browsers, all devices)
WebM (VP9 or AV1)
Google's open video format. VP9 is widely supported; AV1 is the next-generation codec with 30-50% better compression than H.264.
- Best for: Web-optimised video, YouTube-style players, when file size matters
- File size: 20-40% smaller than H.264 at equivalent quality
- Browser support: VP9: Chrome, Firefox, Edge, Android. AV1: Chrome 70+, Firefox 67+, Safari 16+. Not supported in older Safari.
Using Both with Fallback
<video controls>
<source src="video.webm" type="video/webm">
<source src="video.mp4" type="video/mp4">
Your browser doesn't support video.
</video>
The browser picks the first format it supports. WebM for modern browsers, MP4 as fallback.
Audio Formats
MP3
The universal audio format. Supported everywhere, good quality at 128-192 kbps for music. Use MP3 when you need maximum compatibility.
- Best for: Podcasts, music playback, voice recordings
- File size: Medium (128 kbps = ~1MB per minute)
AAC (in MP4/M4A)
Better quality than MP3 at the same bitrate. The default audio codec for MP4 video and Apple's ecosystem. Supported by all modern browsers.
- Best for: High-quality audio at smaller file sizes than MP3
- File size: 15-20% smaller than MP3 at equivalent quality
Opus
The most efficient audio codec available. Better quality than MP3 and AAC at half the bitrate. Supported by Chrome, Firefox, Edge, and Android (not Safari before 16.4).
- Best for: Real-time communication (WebRTC), streaming, web-optimised audio
- File size: 64 kbps Opus ≈ 128 kbps MP3 in quality
Audio with Fallback
<audio controls>
<source src="audio.opus" type="audio/ogg; codecs=opus">
<source src="audio.mp3" type="audio/mpeg">
Your browser doesn't support audio.
</audio>
Recording Media in the Browser
The MediaRecorder API lets you record audio and video directly in the browser, without any server-side processing:
async function startRecording() {
const stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
});
const recorder = new MediaRecorder(stream);
const chunks = [];
recorder.ondataavailable = e => chunks.push(e.data);
recorder.onstop = () => {
const blob = new Blob(chunks, {type: 'video/webm'});
const url = URL.createObjectURL(blob);
// Download or play back
};
recorder.start();
}
The browser picks the best available codec automatically. Chrome and Firefox default to WebM with VP9/Opus; Safari defaults to MP4 with H.264/AAC.
Optimising Video for the Web
- Resolution: Don't serve 4K video to mobile users. Use multiple resolutions or adaptive streaming (HLS/DASH)
- Bitrate: 1080p: 3-5 Mbps, 720p: 1.5-3 Mbps, 480p: 0.5-1 Mbps. Adjust based on content complexity
- Audio: 128 kbps for music, 64 kbps for speech
- Duration: Keep web videos under 2-3 minutes when possible. Use lazy loading for longer content
- Poster image: Show a thumbnail before the video loads
Streaming Protocols
For videos longer than a few minutes, use adaptive streaming:
- HLS (HTTP Live Streaming): Apple's protocol, supported by Safari natively and other browsers via hls.js. Breaks video into segments and adapts quality to bandwidth.
- DASH (Dynamic Adaptive Streaming over HTTP): Open standard, supported by dash.js. Similar to HLS but not natively supported in Safari.
For short clips and simple sites, a single MP4/WebM file with the <video> element is sufficient.
The media tool on this site uses the MediaRecorder API to record audio and video in your browser. No plugins, no server-side processing — everything happens locally on your device. Recordings are never uploaded, making it safe for private content.