What Is A Codec Tag?
codec-tag
You may know what a codec is, but what about the Codec Tag? Find out how to read the Codec Tag of a video and how to get from it to the actual codec that was used.
The Codec Tag is a short code stored inside a video or audio file that names the codec its content was packed with. It is the same information as the codec name, only written as a number instead of a word.
Where the Codec Tag comes from
You will find it in video and audio files, above all in the MP4, MOV and M4A family and in older AVI and WAV files. It is written automatically by the program that encoded the file, at the moment the file was made. Nobody types it in, and it cannot be edited meaningfully on its own: it is a label that has to match the data behind it.
Not every container uses tags. Matroska and WebM files identify their codecs by name instead, so in those files the tag is empty and shows up as 0x0000.
What the value looks like
The value is a number written in hexadecimal, a way of writing numbers that uses the digits 0 to 9 and the letters a to f. The 0x at the front is just a marker saying so. Typical values are 0x31637661, 0x7634706d and 0x0000.
Most of these numbers are a FOURCC, a four-character code. It is a way of packing four letters or digits into a single number, introduced by Microsoft to label video streams and still used by the MP4 family today. You can translate it back by hand. Split the number into four pairs of hex digits and read each pair as a character:
0x31= 10x63= c0x76= v0x61= a
Those four characters are stored back to front, so 0x31637661 reads as avc1, the tag used for H.264 video in MP4 files. The same trick on 0x7634706d gives v, 4, p, m, which read backwards is mp4v. Many reports save you the arithmetic and print the readable form on a second row next to the number.
Audio inside AVI and WAV files is the exception. There the tag is not four characters but a small Microsoft audio format number, so you see short values such as 0x0001, which stands for uncompressed PCM audio.
Why it matters
The tag is one of the first things a player or a device looks at when it opens a file, so it is a compatibility field. The same video data can be labeled with different tags depending on which container it was put into, and a player that only recognizes one of them will refuse the file even though the right decoder is sitting there installed. That is why comparing the Codec Tag of a file that plays with one that does not is a quick way to narrow down a playback problem, especially on TVs, car stereos and other fixed-function devices.
It also confirms what you actually have. A file can be named anything, but the tag is written by the encoder and describes the real content. It holds no information about you, the place or the device.