---
title: "Video Codec: What a Codec Does and Which One to Use - CE.SDK Glossary"
description: "A video codec compresses video and decodes it for playback. Compare H.264, H.265, VP9 and AV1, and see which fits downloads, web players and Apple devices."
url: "https://img.ly/glossary/video-codec/"
type: "page"
---

> This is the markdown version of [Video Codec: What a Codec Does and Which One to Use - CE.SDK Glossary](https://img.ly/glossary/video-codec/). For all pages in one file, see [llms-full.txt](https://img.ly/llms-full.txt). For an index of all available pages, see [llms.txt](https://img.ly/llms.txt).

---

# Video Codec

## What Is a Video Codec?

A video codec compresses video into a much smaller stream for storing and sending, then decodes that stream back into pictures for playback. The name joins its two halves, the coder and the decoder.

Names such as H.264 and AV1 refer to standards. A standard fixes the format of the stream and the steps for decoding it, so every player rebuilds the same picture, but it leaves each encoder free to decide how to compress. That is why x264 and OpenH264, two encoders for H.264, can make different files from the same video.

The codec's output is only part of the file. A container such as MP4 or WebM holds it together with the audio, which has its own codec, and a little metadata. In the two CE.SDK exports drawn here, an H.264 MP4 and a VP9 WebM, the video track took 87% and 93% of the file.

## What Is the Difference Between a Codec and a Container?

The codec is the method that compresses a track, and the container is the file format that stores the compressed tracks. MP4 and WebM are containers, not codecs.

### The codec compresses each track

Video codecs such as [H.264](https://img.ly/glossary/h264.md), H.265, VP8, [VP9](https://img.ly/glossary/vp9.md) and [AV1](https://img.ly/glossary/av1.md) compress the picture, and [audio codecs](https://img.ly/glossary/audio-codec.md) such as AAC and [Opus](https://img.ly/glossary/opus-codec.md) compress the sound. A player needs the matching decoder for each track to play the file.

### The container stores the tracks in one file

Next to the tracks, a container keeps metadata such as the duration and the index a player uses to find each frame. An MP4 can hold H.264, H.265, AV1 or VP9, and WebM, built on [Matroska](https://img.ly/glossary/mkv-vs-mp4.md), takes VP8, VP9 or AV1 with Opus or Vorbis audio, one reason [WebM and MP4](https://img.ly/glossary/webm-vs-mp4.md) suit different jobs.

## Which Video Codec Should You Use?

Where the video will play decides the codec. A course platform, for example, might give students an H.264 MP4 to download and stream the same lesson as AV1 in WebM inside its own web player. When the choice is between H.264 and H.265, the [H.264 vs H.265](https://img.ly/glossary/h264-vs-h265.md) entry compares their file sizes, encoding work and playback support, and [AV1 vs HEVC](https://img.ly/glossary/av1-vs-hevc.md) does the same for AV1 and H.265.

### Use H.264 in MP4 for

- **Files people download or send on** — MDN notes that every major browser plays an MP4 file holding H.264 and AAC.

- **Uploads to video platforms** — YouTube's recommended upload settings ask for H.264 in an MP4 container.

- **Sharing with devices you know nothing about** — Apple's own devices may share their H.265 clips as H.264 when the receiving device can't play the newer format.

### Use AV1 or VP9 in WebM for

- **Video in your own web player** — MDN's first pick for video on a website is AV1 with Opus audio in WebM, well supported apart from Safari on older Apple devices.

- **Video with a transparent background** — VP9 in WebM can carry an alpha channel, though Safari does not support transparency in it. CE.SDK can keep that transparency in WebM exports made on iOS, macOS and Android or with its native Node.js package.

### Use H.265 in MP4 for

- **Video for Apple devices** — Apple builds H.265 support into its devices and says the format keeps the same visual quality as H.264 in less storage.

- **Smaller files that have to stay MP4** — Apps and services that accept only MP4 can still get the smaller H.265 file, as long as their players decode it.

## How Video Codecs Work in CE.SDK

Your users can work with H.264 and H.265 video from [MP4 or MOV files](https://img.ly/glossary/mp4-vs-mov.md) in [CE.SDK video editing](https://img.ly/products/video-sdk.md), along with VP9 and AV1, on Web, iOS, Android and Server. On export, your app decides which container and codec each video gets.

### 01: Check which encoders the device has

In the browser, CE.SDK encodes with the browser's own video encoders, so what the browser supports decides what your users can export. Call `checkCapabilities()` once, then read the state of the codec you want, such as `av1Encode`. CE.SDK never falls back to another codec: one the browser cannot encode fails the export.

### 02: Pick the container, then the codec

In CE.SDK, an MP4 export takes H.264 or H.265 and a WebM export takes VP8, VP9 or AV1, and any other pair fails. Left on Auto, CE.SDK writes H.264 into MP4 and VP9 into WebM. H.265 works only on browsers and mobile platforms that support it, and the native Node.js package exports H.264 MP4 or WebM.

### 03: Expect audio and a cover to match the container

MP4 exports carry AAC audio, or Opus in a browser that can encode Opus but not AAC, such as Firefox. WebM exports carry Opus. Every MP4 also embeds a PNG cover image up to 512 × 512 pixels, 190 KB in the export shown above, and your app chooses the frame it shows.

## FAQs

### Video Codec

**Q: Why does a video play in one app but not another?**

A: Usually the app can open the container but has no decoder for the codec inside it. Two .mp4 files can hold different codecs, so a player that handles H.264 may still fail on H.265 or AV1, and MDN's container guide notes that support for a container says nothing about the codecs in it. When a video won't play, check the codec first.

**Q: Does a video codec compress the sound too?**

A: No, the audio track has a codec of its own, such as AAC or Opus, and each container accepts only some of them. In the two exports in the diagram above, the sound took 5% to 7% of each file, so the video codec accounts for most of the size.

**Q: Why can two videos with the same codec and bitrate look different?**

A: The encoder and the footage change the result as well. Two encoders for the same codec make different choices, and the amount of detail and motion in a scene decides how far a bitrate stretches.

**Q: How can you tell which codec a video uses?**

A: Open it in a tool that reads the file's track headers, such as FFmpeg's ffprobe. Each track stores a short code for its codec. The CE.SDK MP4 exports we checked labeled their tracks avc1 for H.264, hvc1 for H.265 and mp4a for AAC, and the WebM files used V\_VP9, V\_AV1 and A\_OPUS. The file extension only tells you the container.

**Q: Is H.265 the same as HEVC?**

A: Yes. HEVC, short for High Efficiency Video Coding, is the standard that ITU publishes as H.265, in the same way that H.264 is also called AVC, for Advanced Video Coding. Apple uses the HEVC name on its devices, and so does CE.SDK's export API.

## Links

- [Video Editor SDK](https://img.ly/products/video-sdk.md): Give your users MP4 and WebM video export with H.264, VP9 or AV1, inside your own app.
- [Export to WebM](https://img.ly/docs/cesdk/js/export-save-publish/export/to-webm-764271.md): Pick VP8, VP9 or AV1, check that the browser can encode it, and export with Opus audio.
- [Export to MP4](https://img.ly/docs/cesdk/js/export-save-publish/export/to-mp4-c998a8.md): Export H.264 or H.265 video, set the bitrate and frame rate, and choose the cover frame.

---

## More Resources

- **[IMG.LY Website](https://img.ly/index.md)** - Creative editing SDKs for photo, video, and design
- **[Documentation](https://img.ly/docs/cesdk/)** - CE.SDK developer documentation
- **[Build with a coding agent](https://img.ly/SKILL.md)** - A skill that adds a CE.SDK editor to an app: it interviews the user, picks a starter kit and builds it
- **[Contact Sales](https://img.ly/forms/contact-sales.md)** - Get a custom quote. A public JSON API accepts the request directly, no account or key needed. Ask your user for consent and their details first.
- **[Free Trial](https://img.ly/pricing.md)** - Start building with CE.SDK
