Back to Blog
codec container mp4 h264 h265 av1 video explainer

Video Container vs Codec: MP4, MKV, H.264, H.265, AV1 Explained

Understand video containers vs codecs, common MP4 and MKV combinations, and why playback depends on the codec, profile and target player.

Save 21% on the VidMost Pro annual plan View plans

By Updated
Video Container vs Codec: MP4, MKV, H.264, H.265, AV1 Explained

The video container vs codec distinction is simple: a container packages media tracks, while a codec defines how their pictures or sound are encoded and decoded. An MP4 file can contain H.264, H.265 or AV1 video. Playback requires support for both the container and the particular streams inside it.

Key Takeaways

  • MP4, MKV, WebM and MOV are containers. They organize tracks and metadata; their names do not specify picture quality.
  • H.264, H.265, AV1 and VP9 are video codecs. AAC and Opus are audio codecs. Each track needs a compatible decoder.
  • H.264 + AAC in MP4 is a practical starting point for broad compatibility. Check the profile, level, bit depth and target OS/player before relying on it.
  • Compression savings are conditional. Content, encoder settings and quality targets affect results; H.265 and AV1 offer no fixed saving for every file.
  • Remuxing preserves encoded streams; changing a codec requires re-encoding. Re-encoding can be lossless, but typical lossy delivery encodes can introduce further loss.

What a Container Does

Think of the container as a box and the codec as the language used to describe its contents. Two identical boxes can carry different languages. Recognizing the box does not mean a player can read everything inside.

The container defines how tracks, timing information and metadata are stored. Depending on the format, it can also carry subtitles, chapters and attachments. A player first parses that structure, then sends each selected track to a suitable decoder.

An extension such as .mp4 is a clue to the container, not proof of its contents. Renaming clip.mkv to clip.mp4 changes neither the container structure nor the encoded tracks. A probe tool reads the actual file rather than trusting its label.

Container × Codec at a Glance

MDN’s media container guide distinguishes container support from codec support. The table below gives examples of codecs each container can carry, not playback guarantees. Check the destination player for the exact combination.

ContainerExample video codecsExample audio codecsContainer support and caveats
MP4H.264, H.265, AV1, VP9AAC, MP3, FLAC, OpusBroad browser container support; H.264 and H.265 decoding can depend on the browser and OS
WebMVP8, VP9, AV1Vorbis, OpusMDN lists container support across major browsers; check the selected codecs separately
MOV (QuickTime)H.264, H.265AAC, ALAC, MP3Support varies by application and codec; MOV support in a desktop player does not imply browser support
MKV (Matroska)H.264, H.265, AV1, VP9AAC, Opus, FLACWebM is based on Matroska, but WebM support does not imply support for arbitrary MKV files
MPEG-TSH.264, H.265AAC, AC-3Used for broadcast and some HLS segments; support depends on the playback environment

Fragmented MP4 is MP4 media organized into fragments; .m4s is commonly used for media segments. A segment can require initialization data and other segments, so it is not necessarily a standalone movie. See adaptive bitrate streaming for how manifests and segments fit together.

What a Codec Does

A video codec defines the representation of pictures; an audio codec does the same for sound. Encoding creates that representation, and decoding reconstructs pictures or audio for playback.

  • H.264 (AVC) is a common choice when broad compatibility matters. Its name alone does not guarantee hardware decoding or support for every profile and level.
  • H.265 (HEVC) can improve compression efficiency over H.264. Use it when the target playback environment supports the required stream characteristics.
  • AV1 is another option for efficient video compression. Decoder availability and encoding cost matter when choosing it.
  • VP9 is another video codec commonly encountered in web media, including WebM files.

No single percentage describes the size advantage of H.265 or AV1 for all material. A fair comparison needs the same source, a defined quality target and specified encoder settings. Preserving an existing H.265 stream in another container does not itself make that stream smaller.

For sound, AAC is a common companion to H.264 in MP4, while Opus is common in WebM. Audio compatibility must be checked independently: a player may decode the picture but reject the audio track. See downloaded video with no sound when the audio may instead be a separate file.

Why Profile, Level and Bit Depth Matter

A codec family includes different stream requirements. Profile describes coding features, level constrains requirements such as processing capacity, and bit depth describes the precision of samples. A device that supports one H.264 configuration need not support every H.264 file.

The codecs parameter can signal more detail than a container MIME type. RFC 6381 defines this signaling; for example, avc1.640028 identifies AVC High profile, level 4.0. A codec string helps describe requirements, but it does not establish that the receiving device meets them.

Why an MP4 File May Not Play

A supported wrapper can contain an unsupported video or audio stream. An incomplete or damaged file can also fail, so a playback error alone does not prove a missing decoder.

Browser support adds OS and hardware conditions. MDN’s video codec guide documents Firefox’s reliance on OS media support for H.264 and Safari’s hardware-decoder requirement for AV1. HEVC support also depends on the browser and playback environment. Check the current compatibility notes for the exact target.

Hardware decoding uses dedicated circuitry; software decoding uses the CPU. Software support can make a codec playable without dedicated hardware, but smooth playback depends on available resources and stream demands. A device release year does not settle that question.

A Short Playback Check

  1. Inspect the actual file. Open it in MediaInfo or use ffprobe input.mp4; identify the container and every video and audio codec.
  2. Record stream details. Include profile, level, bit depth, resolution and frame rate where reported.
  3. Check the destination. Compare those details with the device or player documentation, including supported containers and audio formats.
  4. Choose the smallest necessary change. If the streams are supported but the wrapper is not, a remux may suffice. If a track is unsupported, use a supported decoder or re-encode that track to a compatible configuration.

For the conversion decision, use the remux vs re-encode guide. Decoder installation belongs in the separate HEVC playback guide for Windows.

Common Questions

Should I Use H.264, H.265 or AV1?

Start with H.264 + AAC in MP4 when sharing across varied devices, then verify the target’s supported profile, level and bit depth. Choose H.265 or AV1 when the receiving software and hardware support the intended stream. Neither choice guarantees a fixed reduction in size or smooth playback.

Can I Change a Codec Without Losing Quality?

Changing the codec requires re-encoding, but re-encoding is not necessarily lossy. A lossless encode can preserve the decoded samples; it cannot restore detail lost in an earlier lossy encode. Typical lossy delivery settings can introduce additional loss. If only the container needs to change, remuxing preserves the encoded streams instead.

Does MP4 or MKV Give Better Picture Quality?

Moving the same encoded video stream between compatible containers does not improve or degrade its picture. Choose the wrapper for track support and the destination player. Separate encoding settings determine picture quality; see bitrate, resolution and file size for that distinction.

Choose for the Destination

Check the wrapper, then each track, then the target’s decoding limits. H.264 + AAC in MP4 is a useful starting point; H.265 and AV1 are options when their requirements fit. Preserve the source when no conversion is needed.

For videos you have permission to save, start with the VidMost homepage and the relevant platform guidance before choosing an offline workflow.

Sources and references

Frequently Asked Questions

Should I Use H.264, H.265 or AV1?
Start with H.264 + AAC in MP4 when sharing across varied devices, then verify the target's supported profile, level and bit depth. Choose H.265 or AV1 when the receiving software and hardware support the intended stream. Neither choice guarantees a fixed reduction in size or smooth playback.
Can I Change a Codec Without Losing Quality?
Changing the codec requires re-encoding, but re-encoding is not necessarily lossy. A lossless encode can preserve the decoded samples; it cannot restore detail lost in an earlier lossy encode. Typical lossy delivery settings can introduce additional loss. If only the container needs to change, remuxing preserves the encoded streams instead.
Does MP4 or MKV Give Better Picture Quality?
Moving the same encoded video stream between compatible containers does not improve or degrade its picture. Choose the wrapper for track support and the destination player. Separate encoding settings determine picture quality; see [bitrate, resolution and file size](/blog/video-bitrate-resolution-file-size-explained/) for that distinction.