A FourCC is a 32-bit identifier made of four 8-bit characters, usually printable ASCII, that names a data type, chunk, box or codec inside a file.
Format registries record FourCC codes as one identifier type among several, next to media types, extensions and registry keys.
Open an AVI file in a hex editor and the first twelve bytes already contain two FourCCs: 52 49 46 46 (“RIFF”) at offset 0 and 41 56 49 20 (“AVI ”, with a trailing space) at offset 8. That pattern, four readable characters doing the job of a binary tag, is the whole idea of the FourCC identifier.
A four-character code is a 32-bit value whose bytes are chosen to be printable characters. Software can compare it in one integer operation; a person reading a hex dump can see what it means. The convention goes back to the OSType codes of the classic Mac OS and to the Interchange File Format (IFF) published by Electronic Arts in 1985, and it was carried into Microsoft and IBM’s RIFF in 1991.
Where FourCC codes appear
RIFF and AVI. Every RIFF chunk starts with a FourCC and a length. WAV files use RIFF, WAVE, fmt and data. In AVI, the stream header carries an fccHandler code and the video format structure carries a compression code; values such as XVID, DIVX, MJPG and H264 tell a player which decoder to load. This is the use most people mean when they talk about “the FourCC of a video”.
QuickTime and MP4. The ISO base media file format (ISO/IEC 14496-12) names every box with a FourCC: ftyp, moov, trak, mdat. Codec sample entries use codes such as avc1 (H.264), hvc1 (HEVC) and mp4a (AAC and related audio). The brand list in the ftyp box (isom, mp42, M4A ) is made of FourCCs as well.
Raw video and pixel formats. Uncompressed and planar layouts are named the same way: YUY2, UYVY, NV12, I420. Video capture APIs and media frameworks rely on these to agree on how pixels are laid out in memory.
Byte order trap
A FourCC is written to the file as four bytes in reading order. Trouble starts when code reads those bytes as an integer. On a little-endian machine, the bytes 52 49 46 46 load as the value 0x46464952, so a constant written as 'RIFF' in C source may or may not match depending on how the compiler builds multi-character constants. Many libraries avoid the problem with a macro that assembles the value from individual characters. When FourCC values appear as hex numbers in documentation, check which convention the author used before copying them into a signature.
FourCC as an identifier type
In a format registry, FourCC sits beside other identifier types such as Internet media types, file extensions and registry keys. Its scope is narrower than a media type: video/mp4 names a container, while avc1 names one possible encoding inside it. A codec record therefore often carries several FourCCs (H.264 in AVI has appeared as H264, h264, X264 and AVC1), and recording all known variants helps catalogers match what tools such as MediaInfo or ffprobe report.
AVI FourCCs have no central authority. Community sites such as fourcc.org collected the codes in circulation, but any codec developer could mint one, and collisions exist. For MP4, the MP4 Registration Authority maintains code points for the ISO family, which makes those codes more dependable. A registry should note the source of each FourCC it records so that a code seen in the wild can be traced to the specification that defines it. More on reading these markers is in the file format identification guide.
Example in RDF
ASCII a v c 1 X V I D A V I (space)
hex 61 76 63 31 58 56 49 44 41 56 49 20
<identifier>
<identifierType>FourCC</identifierType>
<identifierValue>avc1</identifierValue>
</identifier>
Questions about FourCC
What does FourCC stand for?
Four-character code. It is a 4-byte value whose bytes are read as characters, so a program can compare it as a single 32-bit number while a human reads it as a short tag such as 'XVID', 'WAVE' or 'moov'.
Why do some FourCC codes end with a space?
A FourCC always has exactly four bytes. Shorter names are padded, usually with the space character 0x20. 'AVI ' and 'fmt ' are the best-known examples, and dropping the trailing space produces a code that no longer matches.
What is the difference between avc1 and H264?
Both label H.264 video. 'avc1' is the sample entry code used in MP4 and QuickTime files; 'H264' is a code used in AVI files, where it identifies the decoder. They belong to different container conventions.
Are FourCC codes case-sensitive?
Yes, in principle the comparison is on bytes, so 'xvid' and 'XVID' differ. In practice, AVI players often map case variants of a codec code to the same decoder, which is one reason the same codec turns up under several FourCCs.
Does a FourCC identify the file format?
Usually it identifies something inside the file: a chunk type, a box or the codec of a stream. The container format is identified separately, for example by the RIFF header or the 'ftyp' box of an MP4 file.