.H264
H.264 Annex B elementary stream
Introduction
An .h264 or .264 file holds H.264 video exactly as an
encoder produced it, with no container around it. H.264, also called AVC or MPEG-4
Part 10, is defined by ITU-T H.264 and ISO/IEC 14496-10, and is the most widely used
video codec. The byte stream layout these files use is described in Annex B of the
standard, which is why they are often called Annex B streams.
The file has no audio, no index and usually no timestamps, so a player has to be told the frame rate. Raw streams are used to test encoders and decoders, and as an intermediate step before the video is put into an MP4 or MKV file.
Software
- FFmpeg and ffplay (Windows, macOS, Linux)
- VLC media player (Windows, macOS, Linux)
- mpv (Windows, macOS, Linux)
- x264, an encoder that writes raw streams (Windows, macOS, Linux)
- GPAC and MP4Box, which puts raw streams into MP4 (Windows, macOS, Linux)
Structure
The stream is a sequence of NAL units (network abstraction layer units). Each one is
preceded by a start code, the bytes 00 00 01 or 00 00 00 01.
To keep a start code from appearing inside a unit by accident, the encoder inserts an
emulation prevention byte 03 after any two zero bytes that would otherwise
be followed by a byte of 03 or less.
The first byte of each NAL unit is its header: one forbidden bit that is always zero,
two bits of nal_ref_idc giving its importance, and five bits of
nal_unit_type. The common types are 7, the sequence parameter set with
the profile, level and frame size; 8, the picture parameter set; 5, a slice of an IDR
frame, where decoding can start; 1, a slice of any other frame; 6, supplemental
enhancement information; and 9, an access unit delimiter that marks the start of each
frame.
000 00 00 01 start code, then SPS (type 7)varies…00 00 00 01 start code, then PPS (type 8)varies…00 00 01 start code, then an IDR slice (type 5)varies…00 00 01 start code, then a slice (type 1) for each following framerepeated