What Is a Codec? Codecs vs Containers Explained
·5 min read
A codec (short for coder-decoder) is the method used to compress and decompress audio or video data, such as H.264, H.265, VP9, AAC, MP3, or Opus. A container (like MP4, MKV, WebM, or MOV) is the wrapper file that holds one or more codec-encoded streams plus metadata. In short: the codec is *how* the media is compressed, and the container is *what file* holds it.
What a codec actually does
Raw video is enormous. A single minute of uncompressed 1080p footage can run into several gigabytes, which is unusable for streaming, storage, or sharing. A codec solves this by throwing away or cleverly re-encoding data so the file becomes a tiny fraction of its original size. H.264 (also called AVC) is the workhorse of the web and can shrink that same minute of 1080p to roughly 60-130 MB depending on the bitrate you target. Its successor, H.265 (HEVC), reaches the same visual quality at about 50% smaller file sizes, which is why 4K content leans on it heavily. VP9 and AV1 are royalty-free codecs used by YouTube and other platforms for similar efficiency gains. Audio works the same way: MP3 typically encodes at 128-320 kbps, AAC delivers cleaner sound at the same bitrate and is the default for most MP4 video, and Opus stays transparent for speech at just 24-32 kbps.
Lossy vs lossless codecs
- Lossy codecs (H.264, H.265, VP9, MP3, AAC, Opus) permanently discard data the human eye or ear is unlikely to notice. You get dramatically smaller files, but each re-encode loses a little more quality. Almost all streaming and web video is lossy.
- Lossless codecs (FLAC for audio, or lossless modes of some video codecs) compress without throwing anything away, so the decoded file is bit-for-bit identical to the source. Files stay large, but quality is perfect. FLAC is popular for music archiving.
What a container does
A container is the file format you actually see, identified by the extension: .mp4, .mkv, .webm, .mov. It bundles the encoded video stream, one or more audio streams, and metadata like subtitles, chapters, timestamps, and track language. Think of it as a box. The box tells you nothing definitive about the codec inside, and that is the single most misunderstood fact about media files. A .mp4 file can contain H.264 video *or* H.265 video, paired with AAC audio, or another combination entirely. The extension only tells you the container is MP4, not which codec encoded the picture, so two files can both be "MP4s" yet behave completely differently: one plays everywhere, the other throws an error on the same device.
Why you get a 'codec not supported' error
When a player says "codec not supported," it usually means it opened the container just fine but doesn't know how to decode the stream inside. Your phone or TV recognizes the MP4 or MKV box, cracks it open, and finds an H.265 or Opus stream it has no decoder for. That's also why an .mkv file sometimes refuses to play even though it's "just a video": MKV is a flexible container that can hold codecs older or pickier hardware never learned. The container is readable; the codec is the roadblock.
The fix is to re-encode the media into a widely supported combination, most reliably H.264 video with AAC audio inside an MP4 container, which plays on virtually every phone, browser, TV, and editor made in the last decade. You can do exactly that with convert to MP4, which repackages the container and, when needed, transcodes the codec so the result is universally playable. Your files are never uploaded, there's no account, no watermark, and it's free.
Converting: changing the codec, the container, or both
- Remuxing moves streams into a new container without touching the codec (for example MKV to MP4). It's fast and lossless because nothing is re-encoded, but it only works if the target container supports the codec.
- Transcoding actually re-encodes the video or audio into a different codec (H.265 to H.264, for example). It takes longer and, with lossy codecs, sheds a little quality, but it's what fixes true "codec not supported" cases.
- Both happens when you change container and codec at once, which is common when preparing footage for an old device or a strict upload requirement.
Which should you worry about?
If a file won't play or won't upload, don't rename the extension, that changes nothing about the codec inside and can corrupt the file. Instead, decide what you need: universal playback means H.264 + AAC in MP4; a smaller file at the same quality means H.265 or a lower bitrate. If your goal is purely to shrink a video for email, messaging, or storage rather than fix compatibility, reach for a dedicated video compressor to drop the bitrate and file size without wrestling with codec settings by hand. It's private, free, and leaves no watermark.
Once the codec-versus-container distinction clicks, media files stop being mysterious. The extension names the box, the codec names the compression inside it, and playback problems almost always come down to a decoder the player doesn't have. When that happens, converting to a standard H.264 MP4 is the safest move, and you can do it in a few clicks with convert to MP4 without uploading your footage anywhere.
Questions
- Is MP4 a codec or a container?
- MP4 is a container, not a codec. It's a wrapper that holds encoded video and audio streams plus metadata. The video inside an MP4 is usually encoded with the H.264 or H.265 codec, and the audio with AAC, but the .mp4 extension alone doesn't tell you which.
- Why won't my MKV file play?
- MKV is a flexible container that can hold codecs your player or hardware doesn't support, such as H.265 or certain audio formats. The player can read the MKV wrapper but lacks the decoder for the stream inside. Converting it to an H.264 MP4 usually fixes playback everywhere.
- What's the difference between H.264 and H.265?
- Both are lossy video codecs, but H.265 (HEVC) achieves roughly 50% smaller file sizes than H.264 at the same visual quality. H.264 has broader device and browser support, so it's the safest choice for universal playback, while H.265 is better for saving space on 4K content.
- Does converting a video always lose quality?
- Not always. Remuxing, which just moves streams into a new container without re-encoding, is lossless. Transcoding to a different lossy codec sheds a little quality each time. If you keep the same codec or use a lossless format, quality stays intact.