Video Formats Explained: Containers vs Codecs
People often lump MP4, MKV and H.264 together. They actually belong to two layers: container and codec. Grasp that distinction and most format questions resolve themselves.
Container: the box that holds content
MP4, MKV, AVI, MOV and FLV are container formats. They package video, audio and subtitle tracks together with metadata. The container decides what can go inside and which players recognise the file.
Codec: how content is compressed
H.264 (AVC), H.265 (HEVC), AV1 and VP9 are video codecs; AAC, MP3 and Opus are audio codecs. Codecs determine compression efficiency and picture quality. The same content encoded differently can vary greatly in size and fidelity.
Why MP4 is the safest bet
MP4 has the widest support for H.264 + AAC, so almost every device and player understands it — hence its default role in web delivery. MKV is more capable (multiple subtitles and audio tracks) but unsupported on some devices.