A video file will not play, and the message says a codec is missing or unsupported. The word shows up in file settings, export menus and error messages, but it is rarely explained. What is a codec, and why does a file depend on one?

A codec is the part that squeezes audio, video or images into a smaller form and turns them back for playback. This guide covers what that means, why raw media is far too big without it, and what a codec does and does not decide about file size. You will also see how to estimate sizes with two calculators.

Coder plus decoder

The word is a blend of "coder" and "decoder." MDN's glossary defines a codec as a program, algorithm or device that encodes or decodes a data stream, and adds that a given codec knows how to handle a specific encoding or compression technology. So a codec can be software, a formula or a chip.

Two jobs make up a codec. Encoding takes the source data and produces compressed data. Decoding takes the compressed data and produces something you can see or hear. The JPEG standard puts it in similar terms: an encoding process takes an image and outputs compressed image data, and a decoding process takes compressed data and outputs an image. An encoder or decoder is a working implementation of those processes.

Why raw video and audio need one

Raw media is huge. Work it out with the formula bytes per second = width × height × bytes per pixel × frames per second.

Worked example. Example: video at 1,920 × 1,080 pixels, 3 bytes (24 bits) per pixel and 30 frames per second. One frame is 1,920 × 1,080 × 3 = 6,220,800 bytes. One second is 6,220,800 × 30 = 186,624,000 bytes, or 1,492,992,000 bit/s. Ten minutes (600 seconds) is 186,624,000 × 600 = 111,974,400,000 bytes, about 112 GB (1 GB is 1,000,000,000 bytes). Now suppose a codec produces a 5 Mbps stream. Ten minutes of that is 5,000,000 × 600 ÷ 8 = 375,000,000 bytes. Ratio: 111,974,400,000 ÷ 375,000,000 = 298.6:1. The 5 Mbps is an assumed value for the example, not a typical figure.

MDN's video codec guide does the same sum with 4 bytes per pixel and gets 248,832,000 bytes per second for high-definition video before compression. Use the video file size calculator to turn a bitrate and a duration into a size.

Audio has the same pattern on a smaller scale. Uncompressed stereo at 44,100 samples per second and 16 bits per sample runs at 44,100 × 16 × 2 = 1,411,200 bit/s. Three minutes is 31,752,000 bytes. At an assumed 128,000 bit/s the same three minutes take 128,000 × 180 ÷ 8 = 2,880,000 bytes, which is 11.025:1. The audio file size calculator does the uncompressed side of this sum for any sample rate, bit depth and length.

What the encoder and decoder each do

Stage Job Example from the guides
Encode Analyze the source and write it in fewer bits A video encoder compares frames and records only what changed
Store or send Carry the compressed stream A file, or a live stream
Decode Rebuild audio or video from the stream Playback or editing

For video, MDN explains that compression typically works by comparing frames, finding where they differ and recording enough to update the previous frame. Periodic key frames are complete frames that repair any accumulated damage. Whether the result is exact or approximate depends on the codec. Most video codecs are lossy, and some lossless ones exist, as covered in lossless vs. lossy compression.

Same codec, different sizes

A codec name does not fix a file's size. A specification can define the compressed format and the decoding while leaving the encoder room to choose. The DEFLATE specification says so openly: it defines the format without reference to a particular compression algorithm, and a compressor need not follow the suggested method to comply. A decoder, by contrast, must accept everything the format allows.

Settings also matter. MDN's audio guide says the higher the bit rate, the larger the encoded file is likely to be. Two files in the same codec can differ a lot in size if one was encoded at a higher bitrate. To size a file, use bitrate and duration rather than the codec name. See what bitrate is and how to calculate video file size.

Codec versus file type

A codec compresses one stream. A container is a file format that holds one or more streams, such as audio and video, along with metadata so they can be stored and played together. MDN's container guide lists video codecs and audio codecs for MP4, and says a FLAC file can only contain FLAC audio data.

The names blur in everyday use. MDN notes that when MPEG-1 Audio Layer III data sits in a file with no video, people call it an MP3 file even though it is formally an MPEG file. For the full split, see codec vs. container.

Common mistakes

  • Calling MP4 or WebM a codec. They are containers. The codec is the method inside, such as AAC for audio.
  • Assuming a codec is always software. MDN's definition includes algorithms and devices.
  • Expecting a codec name to predict file size. Bitrate, duration and encoder settings decide that. The name only tells you how to read the stream.
  • Assuming every player can decode every codec. A file plays only where a decoder for its codec is available, and support differs.
  • Re-encoding a lossy file repeatedly. MDN's audio guide warns that lossy loss is compounded by recompression. Keep an original and encode from it once.

FAQ

What does codec stand for?

It is a blend of "coder" and "decoder." Some references write it as COder/DECoder.

Is a codec the same as a file format?

No. A codec compresses and decompresses a stream. A file format, such as a container, packages one or more streams. One container can hold several different codecs.

Can a codec be lossless?

Yes. FLAC is a lossless audio codec, so decoding returns the original samples exactly. Most video codecs are lossy and trade detail for size, according to MDN's video guide.

Does the codec decide how big my file is?

Not alone. The size follows from the bitrate and the duration, as in size = bitrate × duration ÷ 8, and the encoder settings help set that bitrate.

Sources

  1. MDN Web Docs, Codec (Glossary). Accessed November 6, 2026.
  2. MDN Web Docs, Web video codec guide. Accessed November 6, 2026.
  3. MDN Web Docs, Web audio codec guide. Accessed November 6, 2026.
  4. MDN Web Docs, Media container formats (file types). Accessed November 6, 2026.
  5. ITU-T (copy hosted by W3C), Recommendation T.81: Digital compression and coding of continuous-tone still images. Accessed November 6, 2026.
  6. IETF, RFC 1951: DEFLATE Compressed Data Format Specification version 1.3. Accessed November 6, 2026.
  7. IETF, RFC 9639: Free Lossless Audio Codec (FLAC). Accessed November 6, 2026.