# AVC / H.264

Canonical URL: https://encode.wiki/codecs/video/avc/
Content version: ca42e61ede0a24f789d7287a0001244ad22f4abf
Status: current
License: CC BY-SA 4.0
Checksum (SHA-256): 5f1b9475f57bc726548839cdbc18add1b7a102223a5b0fb6f166a24db376c815

H.264, also called Advanced Video Coding (AVC) or MPEG-4 Part 10, was developed jointly by ITU-T and ISO/IEC MPEG and first published in 2003. It is published as ITU-T H.264 and ISO/IEC 14496-10; the current ITU-T edition is from June 2026.

H.264 is still the most compatible video format there is. Every browser, phone, TV, game console, editing application and hardware video block from the last fifteen years decodes 8-bit 4:2:0 H.264. Newer codecs ([HEVC](/codecs/video/hevc/), [VP9](/codecs/video/vp9/), [AV1](/codecs/video/av1/)) need substantially less bitrate for the same quality, but none of them plays everywhere.

## When to use H.264

- **Compatibility.** The fallback rendition in any streaming ladder, and the safe choice for files sent to people whose devices you don't know.
- **Live streaming and recording** where hardware encoders and low-latency decoders matter more than bitrate.
- **Low-effort workflows.** [x264](/tools/software-encoders/x264/) is mature, fast and well understood; at high bitrates the efficiency gap to newer codecs narrows.

For new delivery where size matters and AV1 or HEVC decode is available, use those instead.

## Profiles

| Profile               | Bit depth | Chroma               | What it adds and where it plays                                                                  |
| --------------------- | --------- | -------------------- | ------------------------------------------------------------------------------------------------ |
| Constrained Baseline  | 8         | 4:2:0                | No B-frames, no CABAC. Old phones, WebRTC (mandatory there, with VP8)                            |
| Main                  | 8         | 4:2:0                | B-frames, CABAC, weighted prediction, interlace. Broadcast and older devices                    |
| High                  | 8         | 4:2:0, monochrome    | 8×8 transform and custom quantisation matrices. **The normal delivery profile; plays everywhere** |
| High 10               | 8–10      | 4:2:0, monochrome    | 10-bit. Rarely hardware-decoded                                                                  |
| High 4:2:2            | 8–10      | up to 4:2:2          | Professional and broadcast contribution                                                          |
| High 4:4:4 Predictive | 8–14      | up to 4:4:4          | 4:4:4, RGB coding and lossless mode. Software decode only on most devices                        |

The standard also defines Baseline and Extended profiles, intra-only variants of the High profiles, and the scalable (SVC) and multiview (MVC, used for 3D Blu-ray) extensions.

10-bit H.264 (High 10, often called "Hi10P") was popular in anime encoding because it reduces banding, but almost no hardware decoders support it, so it plays only in software players. NVIDIA's RTX 50 (Blackwell) GPUs are a recent exception for H.264 4:2:2 decode and encode; most other hardware stops at 8-bit 4:2:0.

## Levels

Levels limit the decoder workload: frame size in macroblocks, macroblocks per second, bitrate and decoded-picture buffer size. They run from 1 to 6.2. Common ones:

| Level | Typical maximum          |
| ----- | ------------------------ |
| 3.1   | 720p30                   |
| 4.0   | 1080p30 (20 Mbit/s Main) |
| 4.1   | 1080p30 (50 Mbit/s Main) |
| 4.2   | 1080p60                  |
| 5.1   | 2160p30                  |
| 5.2   | 2160p60                  |

The decoded-picture buffer limit means that the number of reference frames allowed falls as resolution rises within a level. x264 picks the level automatically from the resolution, frame rate, reference count and VBV settings. When a device needs a specific level, set it (`-level 4.1` in FFmpeg, `--level 4.1` in x264). Both lower the reference count to fit the level's buffer, but neither enforces the bitrate limit: x264 only warns. Set `-maxrate`/`-bufsize` (`--vbv-maxrate`/`--vbv-bufsize`) to the level's or the device's limits as well.

## Coding tools

H.264 introduced most of the ideas later codecs refined:

- 16×16 macroblocks, split into partitions down to 4×4 for motion compensation, with quarter-pel motion vectors.
- Multiple reference frames (up to 16) and B-frames that can themselves be used as references (B-pyramid).
- Weighted prediction, which helps with fades.
- 4×4 integer transforms, plus 8×8 in High profile.
- Two entropy coders: CAVLC, and the more efficient CABAC (Main profile and above).
- An in-loop deblocking filter.
- Field and frame coding for interlaced video (PAFF and MBAFF).

## Encoders and decoders

**H.264 implementations**

| Relationship | Project or format | Evidence and scope | Status |
| --- | --- | --- | --- |
| Implements by | [x264](/tools/software-encoders/x264/) | x264 is VideoLAN's H.264/AVC software encoder. Scope: Encoder. Sources: [x264 source repository and license](https://code.videolan.org/videolan/x264), [ITU-T H.264 — Advanced video coding for generic audiovisual services](https://www.itu.int/rec/T-REC-H.264). | Documented |

[Open the complete typed relationship catalog](/api/v1/catalog.json).

- **[x264](/tools/software-encoders/x264/)** is the reference point for H.264 quality and the encoder to use for software encoding. It is GPL-licensed, with commercial licenses available.
- **OpenH264** (Cisco) encodes and decodes Constrained Baseline only and targets realtime use such as WebRTC.
- **[JM](/tools/software-encoders/jm/)** is the reference software, useful for conformance work, not production.
- **Hardware encoders**: [NVENC](/tools/hardware-encoders/nvenc/), [Quick Sync](/tools/hardware-encoders/qsv/), [AMF](/tools/hardware-encoders/amf/), [VideoToolbox](/tools/hardware-encoders/videotoolbox/), [MediaCodec](/tools/hardware-encoders/mediacodec/), [VA-API](/tools/hardware-encoders/vaapi/) and [Vulkan](/tools/hardware-encoders/vulkan/). Fast and low-power, but they need more bitrate than x264's slower presets for the same quality.

FFmpeg's native `h264` decoder handles all the profiles in the table above in software. Hardware decode of 8-bit 4:2:0 High profile is universal.

A widely compatible file from FFmpeg:

```sh
ffmpeg -i input.mkv -c:v libx264 -preset slow -crf 20 -pix_fmt yuv420p -c:a aac -movflags +faststart output.mp4
```

`-pix_fmt yuv420p` matters: given RGB, 4:4:4 or 10-bit input, libx264 otherwise keeps that format and produces a High 4:4:4 Predictive or High 10 stream that browsers and phones won't play. `-movflags +faststart` moves the index to the start of the file so web playback can begin before the download finishes. x264's default CRF is 23; lower values give higher quality and larger files. See [x264](/tools/software-encoders/x264/) for presets and tuning.

## Containers

**H.264 container mappings**

| Relationship | Project or format | Evidence and scope | Status |
| --- | --- | --- | --- |
| Carried By | [ISO Base Media File Format](/containers/isobmff/) | MP4RA registers AVC sample entries including avc1 and avc3. Scope: Container Mapping. Sources: [MP4 Registration Authority codec registry](https://mp4ra.org/registered-types/codecs). | Registered |
| Carried By | [Matroska](/containers/matroska/) | The Matroska mapping uses V_MPEG4/ISO/AVC and an AVCDecoderConfigurationRecord. Scope: Container Mapping. Sources: [Matroska codec mappings](https://www.matroska.org/technical/codec_specs.html). | Documented |

[Open the complete typed relationship catalog](/api/v1/catalog.json).

| Carriage       | Identifier / form                       | Notes                                                                                     |
| -------------- | --------------------------------------- | ----------------------------------------------------------------------------------------- |
| MP4, MOV       | `avc1` or `avc3` sample entry           | `avc1` keeps parameter sets in the header (most compatible); `avc3` allows them in-band   |
| Matroska       | `V_MPEG4/ISO/AVC`                       | Configuration record in `CodecPrivate`                                                    |
| MPEG-TS, HLS   | Annex B byte stream                     | Start-code format; FFmpeg converts automatically when remuxing to MP4/MKV                |
| RTP / WebRTC   | RFC 6184 payload format                 | Packetisation mode is negotiated in SDP                                                   |
| FLV / RTMP     | AVC in FLV                              | Still the usual ingest format for many streaming platforms                               |

Avoid AVI for H.264: it has no proper support for B-frame timestamps.

## Colour and HDR

H.264 carries colour primaries, transfer characteristics and matrix coefficients in the VUI, so a 10-bit PQ or HLG stream is technically possible. In practice HDR delivery uses HEVC, AV1 or VP9, because players and devices don't expect HDR in H.264; consumer H.264 means SDR BT.709.

## Licensing

H.264 is patent-encumbered. [Via LA](https://www.via-la.com/licensing-programs/avc-h-264/) (formerly MPEG LA) runs the main patent pool covering encoders, decoders and some commercial content distribution. Many early H.264 patents have expired, but the pool still licenses the remaining ones. Cisco ships prebuilt OpenH264 binaries and pays the pool royalties for them, which is how Firefox and other open-source projects get licensed H.264 for WebRTC. x264's GPL license covers copyright only, not patents.

## Pitfalls

- **Wrong pixel format** (see the command above): RGB, 4:4:4 or 10-bit input produces streams that only software players decode.
- **Level too high for the target.** Older TVs and set-top boxes may reject streams above level 4.1; set the level and VBV as described above.
- **Interlaced sources.** Deinterlace before encoding for web delivery; interlaced H.264 is a broadcast format and many players display it badly.
- **High bitrates hide the codec's age; low ones don't.** Below a few Mbit/s at 1080p, H.264 shows blocking and smearing that AV1 or HEVC avoid.
