Unsupported Browser

This page probably won't work great in Internet Explorer. We generally only support the recent versions of major browsers like Chrome, Firefox, Safari and Edge.

H264 is a standard for video compression. It is also known as MPEG-4 AVC (Advanced Video Coding) or MPEG-4 Part 10.
It is designed to deliver good video quality at very low bitrates, for instance for telephony systems, but also to scale very well at high resolutions and bitrates.

A dvanced V ideo C oding

It was hard to imagine, back in 2005, when H.264 was added to QuickTime 7, that it would not be one more codec, but — fueled by the smartphone, social media, and fast Internet triad —  a defining technology of our age.

It is still by far the most commonly used format for the recording, compression, and distribution of video content.

Usage of H.264

Cameras supporting AVC video recording have started shipping around 2009, when H.264/AVC encoding chips were becoming mainstream. A decade later, H.264 is still the dominating recording format, ranging from low-end to production:

H.264 is a versatile video codec, it can be used in a variety of multimedia formats:

AVCHD is the brand name for H.264 packaged inside a MPEG transport stream, inside .MTS files.

The format, mainly used in Sony and Panasonic cameras, is limited to fullHD, and nowadays seldom used.
When used inside MOV or MP4 file format — Lumix GH5, Sony A7, Canon EOS, GoPro, DJI — H.264 video codec is paired with one or several audio channels.

The video stream doesn't usually contain the PPS and SPS units, which are encoded in the avcC structure found inside stsd atom.
See details in “H.264 analysis” section.
For their 4K cameras, the Big Three — Sony, Canon, Panasonic — developed H264/MXF combos branded XAVC, XF-AVC and AVC Intra respectively.

Stream is encoded as “Annex B” instead of length-prefixed avcC.

How H.264 encoding works

To explain what happens at high-level, we will simulate a video recording with this Panasonic Lumix S1H camera.


  1. Camera configures the AVC chip using the avcC corresponding to this mode:
  2. Camera creates an empty MDT file and writes the MOV header
  3. Images from sensor are ingested by AVC encoding chip, which yields media data —  the encoded images
  4. Camera writes media data to the MDT file. Not just video, also encoded audio, which is stored interleaved with video in the file
  5. Camera wraps the file by adding the moov database and changes its extension to .MOV

Try Treasured on your corrupted H.264 files!

Our service offers:

  • FREE diagnostics and preview with Treasured
  • FREE sample of repaired video
  • Try before you buy with a FREE trial of your Repair Kit
  • Enjoy FREE customer support by speaking directly with our trained experts
  • Invaluable expertise, dedication and second to none customer service
Video Repair app online


Video Repair — online

Mac, Windows, Linux

Click to try

H.264 analysis

Unlike proprietary codecs, H.264/HEVC is an international standard:
Codec specification is public, we can provide give here a few pointers about how it works.

Anatomy of a H264 movie

We take as example a MP4 file with a H.264 video track.
This information is also valid in case of a MOV file.

Inside a MP4 container, H.264 has the following characteristics:


0000000: 0000 0030 6674 7970 6d70 3432 0000 0001  ...0ftypmp42....
0000010: 6d70 7034 6176 6331 0000 0000 0000 0000  mp42avc1........
0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
0000030: 0000 0008 7769 6465 0bbf 4f9d 6d64 7461  ....wide..O.mdta

where mp42 indicates MP4 container and avc1 indicates H.264/AVC encoding.


Immediately after mdat tag, we find media data. Here, it starts directly with a H.264 keyframe:

0000040: 0001 218f 6588 8401 ace3 7fee 2732 d332  ..!.e.......'2.2
0000050: 1cd1 5998 23af c258 aefa 8e46 9089 41b9  ..Y.#..X...F..A.
0000060: 9230 355e 3e71 ad9c 30df f6f2 68e9 f5bb  .05^>q..0...h...

where hexadecimal value 0x1218f corresponds to the length of the frame
and the NAL header 0x6588 indicates that this is a keyframe — aka an Intra frame.

Videos made only of such frames are called All-Intra or All-I.
Other values are possible for a NAL header: 0x619a stands for a Progressive or P frame.

Sample Description

Deep inside the moov database — found either at the beginning or at the end of the file — the stsd atom contains the H.264 encoding settings necessary to decode the video.

bbf4fd3: 0000 0088 7374 7364 0000 0000 0000 0001  ....stsd........
bbf4fe3: 0000 0078 6176 6331 0000 0000 0000 0001  ....avc1........
bbf4ff3: 0000 0000 0000 0000 0000 0000 0000 0000  ................
bbf5003: 0cc0 0730 0048 0000 0048 0000 0000 0000  ...0.H...H......
bbf5013: 0001 0a41 5643 2043 6f64 696e 6700 0000  ...AVC Coding...
bbf5023: 0000 0000 0000 0000 0000 0000 0000 0000  ................
bbf5033: 0000 0018 ffff 0000 0022 6176 6343 014d  ........."avcC.M
bbf5043: 0028 ffe1 000a 2742 001f a908 0198 073c  .(....'B.......<
bbf5053: 0100 0528 ef06 f2c0 0000 062d 6672 6565  ...(.......-free


where avc1 indicates the codec used,
0x0cc0 is the picture width, and 0x0730 the picture height — in decimal 3264 x 1840,
and where the avcC structure (whose length is 0x22) contains encoding settings, formatted according to the sequence header format:

Tokens 0x27 and 0x28 indicate the PPS and SPS structures respectively, prefixed by their respective length.

Fixing MOV files MP4 files Reindexing

Related Topics


How do we recover corrupted H.264 videos?

Since 2009, Treasured can detect the presence of H.264 media inside a corrupted file or a wiped card, and show a preview of the video.

Repairing the video

We develop a Repair Kit — a program able to fix bad H.264 files — specifically for your videos. The Repair Kit uses an algorithm called Reindexing to yield good video out of unplayable media data.

Reindexing produces a video with the same quality as originally recorded, because media is not re-encoded or altered, just rewrapped as-is.

To fix a corrupt video containing H264, it is sometimes necessary, and always helpful, to have a good file similarly encoded. Even if the good file contains only a few frames, the fact that it was encoded with the exact settings of the damaged clip will provide useful information:

  • Sample description — usually found in the avcC structure of a stsd atom
  • Distribution of frames between I, P and B types (stsc, stsz, stss tables)
  • Composition offsets, if used (ctts table)
  • Distribution of blocks inside a frame

This information can be guessed from a broken H264 file, but through a lengthy trial-and-error iterative process.