Codec vs Container: MKV, MP4, H.264 and HEVC Explained

A codec describes how audio or video is encoded and decoded. A container packages those streams together with items such as subtitles, chapters, and metadata. Confusing the two is one of the main reasons playback problems are misdiagnosed.

Quick answer

MP4, MKV, MOV, AVI, and WebM are containers. H.264/AVC, HEVC/H.265, AV1, AAC, AC3, and DTS are codecs. A familiar container can still fail to play when one of the streams inside uses a codec the current playback path cannot decode.

Container

A container is the file structure that holds one or more media streams and related information.

Examples: MP4, MKV/Matroska, MOV/QuickTime, AVI, WebM, MPEG-TS.

Codec

A codec defines how a video or audio stream is compressed/encoded and decoded for playback.

Video: H.264, HEVC, AV1, MPEG-2, ProRes.
Audio: AAC, AC3, EAC3, DTS, FLAC, MP3.

One container can hold many different codecs

movie.mp4\n├─ Container: MP4\n├─ Video: H.264 / AVC\n└─ Audio: AAC\n\nmovie-4k.mp4\n├─ Container: MP4\n├─ Video: HEVC / H.265\n└─ Audio: EAC3

Both files end in .mp4, but they require different decoding support. That is why “MP4 works on my computer” does not guarantee that every MP4 file will play.

Common containers and codecs

NameTypeCommon role
MP4ContainerCommon delivery container for H.264, HEVC, AV1 and AAC-based media.
MKV / MatroskaContainerFlexible container for many video, audio and subtitle formats.
MOV / QuickTimeContainerCommon in phones, cameras, editing and Apple workflows.
AVIContainerOlder Windows-era container that can hold many legacy codecs.
H.264 / AVCVideo codecVery widely supported HD and web/video codec.
HEVC / H.265Video codecMore efficient compression, common in 4K, HDR, phones and cameras.
AV1Video codecModern high-efficiency codec used in newer web and distribution workflows.
AACAudio codecCommon audio codec in MP4 and streaming media.
AC3 / EAC3Audio codecCommon surround-sound formats in video media.
DTSAudio codecSurround-sound format often found in disc-derived or MKV media.

Why this matters when a file will not play

  1. If Windows recognises the container but cannot decode the video stream, you may see black video or an unsupported-video message.
  2. If the video stream works but the audio codec is unsupported, the picture may play normally with no sound.
  3. If neither stream is the problem, investigate corruption, incomplete transfers, DRM, hardware acceleration, player configuration, or output devices.

Inspect a media file Troubleshoot playback

Frequently asked questions

Is MP4 a codec?

No. MP4 is primarily a container. It can hold H.264, HEVC, AV1, and other video streams together with audio such as AAC.

Is MKV a codec?

No. MKV (Matroska) is a container. Its flexibility is one reason two MKV files can have very different playback requirements.

What is the difference between H.264 and MP4?

H.264 is a video codec; MP4 is a container. H.264 is commonly stored inside MP4, but MP4 can also contain other codecs.

Related guides