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.

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.

Advertisement

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.

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.

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).

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

Streaming Protocols

For videos longer than a few minutes, use adaptive streaming:

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.