# Choose the right codec

Decision tree for picking the best video codec for your use case

Picking a codec is a tradeoff between file size, encode speed, and device support. Start with your delivery target and work backwards.

## Decision tree

**Where will the video play?**

- **Web browsers (widest reach)** -- use `h264`. Every browser, every device. No questions.
- **Web browsers (modern only)** -- use `av1`. 30-50% smaller than h264. Chrome, Firefox, Edge, Safari 17+.
- **Apple devices (native apps)** -- use `h265`. Native hardware decode on all iPhones, iPads, Macs, Apple TVs.
- **Android apps** -- use `h265`. Hardware decode on modern Android (API 24+).
- **Open-source / royalty-free requirement** -- use `vp9` in WebM. No licensing concerns.
- **Archival / maximum compression** -- use `av1`. Best compression ratio available today.
- **Fast turnaround / high volume** -- use `h264`. Fastest encode, lowest compute cost.

## Codec comparison

| Codec  | Container | Browser support                   | Relative file size | Encode speed | Decode complexity | Licensing                   |
| ------ | --------- | --------------------------------- | ------------------ | ------------ | ----------------- | --------------------------- |
| `h264` | mp4       | Universal                         | Baseline (1x)      | Fast         | Low               | Licensed (widely available) |
| `h265` | mp4       | Safari, Edge, Chrome (partial)    | ~0.7x              | Medium       | Medium            | Licensed (royalties)        |
| `vp9`  | webm      | Chrome, Firefox, Edge             | ~0.7x              | Medium       | Medium            | Royalty-free                |
| `av1`  | mp4, webm | Chrome, Firefox, Edge, Safari 17+ | ~0.6x              | Slow\*       | High              | Royalty-free                |

\*AV1 encoding is slow sequentially. Ittybit splits video into chunks and encodes in parallel, making it practical for production use.

## Rules of thumb

1. **Default to h264** unless you have a specific reason not to. It works everywhere and encodes fast.
2. **Use AV1 when bandwidth matters** -- video-heavy platforms, mobile users on metered connections, CDN cost reduction.
3. **Use h265 for native apps** -- if your video plays in AVPlayer (iOS) or ExoPlayer (Android), h265 gives you smaller files with hardware decode.
4. **Use VP9 for open-source** -- when licensing matters more than Apple compatibility.
5. **Encode multiple codecs** when your audience spans browsers and devices. Serve the smallest format each client supports.

## Common mistakes

- **Picking AV1 for everything** -- encode time and cost are higher. Not worth it for short-lived or low-traffic content.
- **Using h265 for web playback** -- browser support is inconsistent. Always pair with an h264 fallback.
- **Ignoring your audience** -- if 90% of your users are on Chrome, VP9 or AV1 covers them. If 40% are on Safari < 17, you need h264.

## Individual codec guides

- [Encode video with AV1](/guides/encode-video-with-av1)
- [Encode video with H.265/HEVC](/guides/encode-video-with-h265)
- [Convert video to WebM](/guides/convert-video-to-webm)
- [Multi-codec encoding pipeline](/guides/multi-codec-encoding-pipeline)
- [Encode video for Apple devices](/guides/encode-video-for-apple-devices)
- [Transcode legacy codecs](/guides/transcode-legacy-codecs)