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.
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:
- Phones, Action cameras, Dashcams
- Panasonic Lumix
- Canon EOS
- Sony A7
H.264 is a versatile video codec, it can be used in a variety of multimedia formats:
The format, mainly used in Sony and Panasonic cameras, is limited to fullHD, and nowadays seldom used.
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.
How H.264 encoding works
To explain what happens at high-level, we will simulate a video recording with this Panasonic Lumix S1H camera.
- Camera configures the AVC chip using the avcC corresponding to this mode:
- Camera creates an empty MDT file and writes the MOV header
- Images from sensor are ingested by AVC encoding chip, which yields media data — the encoded images
- Camera writes media data to the MDT file. Not just video, also encoded audio, which is stored interleaved with video in the file
- 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
Treasured
Video Repair — online
Mac, Windows, Linux
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:
Header
0000000: 0000 0030 6674 79706d70 3432 0000 0001 ...0ftypmp42 .... 0000010: 6d70 70346176 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
Frames
Immediately after
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 00000022 6176 6343 014d ........."avcC .M bbf5043: 0028 ffe1000a 27 42 001f a908 0198 073c .(....'B.......< bbf5053: 0100 0528 ef06 f2c0 0000 062d 6672 6565 ...(.......-free
where
and where the
Tokens 0x27 and 0x28 indicate the PPS and SPS structures respectively, prefixed by their respective length.
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.