Back to Blog

Video Containers vs Codecs: MP4, MKV, H.264, H.265, AV1 Explained

A container is the box, a codec is what's inside. Plain-English guide to MP4, MKV, WebM, H.264, H.265, AV1, VP9, and why your .mp4 file sometimes won't play.

By

You download a video, double-click it, and get an error: “Cannot play this format.” But the file is .mp4, and .mp4 is supposed to be universal. You try it in QuickTime — nothing. You try it in your browser — black screen with audio. You try it in VLC and it finally plays. What went wrong?

The short answer is that the file extension lied to you. .mp4 doesn’t tell you what’s in the file; it only tells you how the contents are packaged. The thing your player can’t decode isn’t the package — it’s the compressed video stream inside, encoded with an algorithm your player doesn’t recognize. Once you understand that one distinction, a huge amount of mysterious video behavior — the codec errors, the “audio plays but no video” glitches, the files that work on your phone but not your TV — turns out to be the same problem wearing different clothes.

A container is the box, a codec is what’s inside, and most playback problems come from confusing the two.

This guide walks through what containers do, what codecs do, which combinations are common in 2026, why “save as MP4” doesn’t always mean “save as something everyone can play,” and how to diagnose a video that refuses to open.

Key Takeaways

  • A container is a file format that packages tracks together — video, audio, subtitles, chapters, metadata. Common containers: .mp4, .mkv, .webm, .mov, .ts, .m4s.
  • A codec is the algorithm that compresses the actual audio and video data. Common video codecs: H.264 (AVC), H.265 (HEVC), AV1, VP9. Common audio codecs: AAC, Opus, MP3, FLAC.
  • The file extension tells you the container, not the codec. A .mp4 file can hold H.264, H.265, or AV1 video — and the difference is what decides whether it plays.
  • H.264 plays on everything modern; H.265 cuts bitrate roughly in half but needs post-2017 hardware; AV1 cuts it further again but needs 2022-or-later devices for hardware decode.
  • H.264 and H.265 are royalty-bearing; AV1 and VP9 are royalty-free — which is why YouTube, Netflix, and Twitch are migrating to AV1.
  • Remuxing changes the container without re-encoding; switching the codec always requires a full re-encode.
  • MP4 with H.264 video and AAC audio is still the safest “just works” combination for files you want to play anywhere.

The Simple Explanation

Imagine you’re shipping a parcel. The cardboard box is the container: it has a shape, a label, and rules about how things fit inside. What’s actually in the box — a book, a phone, a vase wrapped in bubble wrap — is the contents. Two parcels with identical cardboard boxes can hold totally different things, and the box doesn’t determine whether you can use what’s inside; that depends on whether you can read the book’s language or charge the phone.

A video file works the same way. The container — .mp4, .mkv, .webm, .mov, .ts, .m4s — is the packaging format. It defines how the file is laid out on disk: where the video track lives, where the audio track lives, where to find subtitle data, where to find the seek index, where to find metadata. The codec — H.264, H.265, AV1, VP9, AAC, Opus — is how the actual compressed bytes inside the video and audio tracks are encoded. The container is the box; the codec is the language the contents are written in.

This split exists because there are two different engineering problems. Packaging a multi-track file so a player can seek instantly to minute 17, switch the audio between English and Japanese, and overlay subtitles is one problem. Compressing a 4K video down to a few megabits per second without it looking like a smudge is a different problem. Containers solve the first; codecs solve the second; they evolve on independent schedules.

Now the awkward part. A .mp4 file can contain H.264 video plus AAC audio — and play in any browser, phone, or media player. The same .mp4 extension can also contain AV1 video plus Opus audio, and that file will refuse to play in Safari 16, on a 2019 iPad, or on an Apple TV from 2020. Same extension. Same container spec. Totally different playability. The container told you nothing about whether the file would play; the codec told you everything.

Once you internalize this, the rest of this article is filling in which codecs are common, which devices support which, and what to do when you have a file that fits the wrong combination.

How Containers and Codecs Actually Work

Every video file has at least two layers: a container that lays out the tracks on disk, and one or more codecs that determine how the data inside each track is compressed. Both layers have to be understood by your playback software for the file to play.

Containers in Detail

A container stores multiple tracks — usually one video track and one or more audio tracks, plus optional subtitles, chapter markers, attachments (fonts, cover art), and metadata. It also typically holds an index or cue table that tells the player which byte offset corresponds to which timestamp, so seeking can jump straight to minute 17 instead of decoding from the beginning.

Common containers in 2026:

  • MP4 — ISO Base Media File Format (ISO/IEC 14496-14). The most universal container by far. Used by streaming services, browsers, mobile cameras, and modern HLS (fMP4 segments inside CMAF). Descended from Apple’s QuickTime MOV. If you need a file to play everywhere, you want MP4.
  • MKV — Matroska. Open, royalty-free, extremely flexible. Supports any codec combination, unlimited tracks, chapter menus, attached fonts, multiple subtitle formats. Popular with desktop video, anime fansubs, and disc rips. Less universally supported by browsers and smart TVs.
  • WebM. Google’s MP4 alternative, optimized for the web. Almost always carries VP9 or AV1 video plus Opus audio. Supported by Chrome, Firefox, and Edge; Safari support arrived late.
  • MOV — QuickTime File Format. Apple’s container, technically the parent of MP4 — the two share most of their internals. Common output from iPhones and Apple’s editing tools.
  • MPEG-TS (.ts). Designed for broadcast satellite and cable TV, where packet loss is a fact of life. Used by legacy HLS segments and some IPTV services. Robust but inefficient compared to fMP4.
  • Fragmented MP4 (.m4s). A variant of MP4 cut into small independent fragments. Used by MPEG-DASH, modern HLS, and the Common Media Application Format (CMAF) so one set of files can serve both protocols. This is what an HLS .m4s segment contains — the same MP4 box structure, just chopped into chunks.

Video Codecs in Detail

Every codec generation trades compression efficiency against encode/decode CPU cost and licensing complexity.

  • H.264 (AVC) — Advanced Video Coding, ITU-T H.264 / ISO/IEC 14496-10. Standardized in 2003 and decoded in hardware by every smartphone, GPU, smart TV, and game console made since roughly 2010. Royalty-bearing — covered by patent pools administered by MPEG LA and others. Still the universal lowest common denominator: an H.264 file in an MP4 container plays anywhere. Most video conferencing, surveillance recordings, and consumer cameras still use it.
  • H.265 (HEVC) — High Efficiency Video Coding, ITU-T H.265 / ISO/IEC 23008-2. Standardized in 2013. Achieves roughly 50 percent better compression than H.264 at the same visual quality, which is the difference between shipping 4K at all and not. Hardware decode is widespread on devices from 2017 onward. The catch is licensing: HEVC patents are split across MPEG LA, HEVC Advance, Velos Media, and several individual holders, which has made the royalty picture messy enough that some browsers (notably Firefox on most platforms) only enable H.265 when the OS already provides hardware decode. Used by Apple TV+, Netflix 4K HDR, and modern HLS/DASH streams to capable clients.
  • AV1 — AOMedia Video 1. Standardized in 2018 by the Alliance for Open Media (Google, Netflix, Amazon, Apple, Microsoft, Mozilla) to escape the HEVC royalty mess. Royalty-free. Roughly 30 percent better compression than H.265. Hardware decode arrived on flagship phones and recent GPUs around 2022 and is now standard on new devices; encoding remains CPU-intensive, so live AV1 is still rare. Used by YouTube, Netflix, and Twitch for high-resolution streams to capable clients.
  • VP9. Google’s predecessor to AV1, released in 2013. Royalty-free. Roughly comparable to H.265 in compression. Used heavily by YouTube before the AV1 rollout and still common as a fallback for devices that decode VP9 but not AV1. Notably absent from Apple’s stack — Safari only added software VP9 decoding recently.

Audio Codecs, Briefly

Audio is usually less of a compatibility headache than video, but the same split applies.

  • AAC. The universal default. Pairs with H.264 in MP4 for maximum compatibility.
  • MP3. Legacy but still ubiquitous, especially for music files.
  • Opus. Modern, open, royalty-free, very efficient at both speech and music bitrates. Default in WebM and used by Discord, WhatsApp, and most VoIP.
  • FLAC. Lossless. Used for archival music, not video soundtracks.
  • Dolby AC-3 and E-AC-3 (Dolby Digital, Dolby Digital Plus). Common in broadcast and 5.1/Atmos streaming surround audio.

Why .mp4 Doesn’t Always Mean H.264

This is the trap that catches most people. MP4 is just the wrapper. An AV1-in-MP4 file is perfectly legal but won’t play in Safari 16, on older Apple TVs, or on any TV without an AV1 hardware decoder. The same applies to H.265-in-MP4 on older devices, VP9-in-MKV on Apple devices, and Opus-in-MP4 on most consumer hardware. When a video “won’t play,” the first question is never “what’s the extension” — it’s “what’s the codec.”

Where Containers and Codecs Meet HLS and DASH

Streaming protocols sit on top of all this. Legacy HLS shipped MPEG-TS segments carrying H.264 + AAC. Modern HLS uses fMP4 segments under CMAF, carrying H.264, H.265, or AV1 depending on the client. DASH’s fMP4 segments use the same container format and can carry any codec the player advertises support for. ABR ladders typically use the same codec across variants — switching codecs mid-stream is technically possible but rare. DRM-protected content uses the same containers and codecs, just encrypted with MPEG Common Encryption layered on top, leaving the codec untouched but the bytes unreadable without a license.

Once you start saving streams off the web, this matrix matters in practice — which is why a tool like VidMost normalizes output to a known-good combination instead of preserving whatever exotic codec the source happened to use.

Real-World Codec Support in 2026

Codec support is fragmented across browsers, devices, and operating systems, and the matrix shifts every year. The summary below is a snapshot of what’s broadly true in 2026.

Browsers. Chrome and Edge play H.264, H.265 (with OS hardware support), AV1, VP9, and VP8. Safari 17+ plays H.264, H.265, and AV1, but its AV1 support requires a device with a hardware AV1 decoder — that means A17 Pro / M3-class chips or newer; there is no software fallback. Historical Safari support for VP9 was missing but improved recently. Firefox plays H.264, AV1, VP9, and VP8 universally and supports H.265 only when the OS provides hardware decode — which works on Apple Silicon Macs and recent Windows PCs but not on most Linux installs.

Mobile and Apple devices. On Apple silicon, hardware AV1 decode arrived with the A17 Pro (iPhone 15 Pro and Pro Max) and the M3 generation of Macs; earlier iPhones, iPads, and Macs don’t get AV1 in Safari at all. Android flagship phones from 2022 onward almost universally include AV1 hardware decode. Older Apple TVs and smart TVs from before 2021 are stuck on H.264 and H.265 only.

Streaming services pick by client. Netflix ships AV1 to capable clients (recent iPhones, modern smart TVs, current-gen consoles) and falls back through H.265 to H.264 on older devices. YouTube does the same, with VP9 as a middle-tier fallback. Twitch is rolling out AV1 for higher-resolution live streams while keeping H.264 as the universal baseline. Apple TV+ delivers H.265 with HDR to Apple devices and falls back to H.264 elsewhere.

Hardware vs software decode. Hardware decode is what makes 4K playback possible on a phone without melting the battery — a dedicated silicon block inside the SoC handles the work at a tiny fraction of the CPU cost. Software decode for an unsupported codec usually works on a desktop with enough CPU headroom (VLC, mpv, and ffplay will gladly software-decode AV1 on a 2018 laptop) but fails or burns battery on phones and embedded devices. When a video plays on your laptop but stutters on your phone, mismatched hardware decode is the most common cause.

A useful mental model: H.264 is the universal default everywhere, H.265 is the safe upgrade if you control the device list, AV1 is the future you can ship to recent hardware today but not assume on anything older than 2022.

What This Means If You Want to Save a Video

This is where the container-versus-codec split stops being academic. If you’ve ever scraped a streaming site, merged a folder of .ts segments, or downloaded a video and discovered your editor refuses to import it, the problem is almost always codec mismatch — not the container.

Three pain points show up over and over:

  • Streaming segments are not in friendly formats. Successfully grabbing the parts of an HLS or DASH stream leaves you with a stack of MPEG-TS files or fragmented MP4 chunks. Consumer players choke on a folder of these; you need to concatenate the segments and remux them into a single MP4 in the right order before they’re playable as one file.
  • Source codecs aren’t always editor-friendly. If the source shipped AV1 to your browser, your video editor may not import AV1, or may stutter during scrubbing because it relies on software decode. Even H.265 is patchy in older editing tools. A file that played fine in the browser becomes useless to anyone trying to do real work with it.
  • Device fragmentation bites at the worst time. You download a 4K H.265 movie for your tablet, sync it to your kid’s older iPad, and find the iPad lacks the right H.265 profile support. Or you save a YouTube AV1 stream and discover the smart TV USB player only speaks H.264.

VidMost’s default output is .mp4 with H.264 video and AAC audio — the most universally compatible combination available, decoded in hardware by every modern phone, TV, browser, and editing tool. Users who want maximum compression or to preserve the source codec (H.265 from a 4K HDR stream, AV1 from YouTube) can configure that, but the default is “just works on everything.” VidMost handles the remuxing automatically: segments are reassembled, codec strings are checked against the output profile, and where re-encoding is needed it’s offered as a clear choice rather than a silent surprise.

Common Pitfalls and Misconceptions

A handful of beliefs about containers and codecs come up over and over in forums. Worth clearing up.

  • “MP4 is a codec.” No, MP4 is a container — specifically the ISO Base Media File Format. The codec inside might be H.264, H.265, AV1, or one of several other things. “In MP4 format” is true but largely useless without knowing the codec.
  • “MKV is better than MP4.” They’re different containers serving different needs, not competing quality levels. MKV is more flexible — more codec combinations, richer metadata. MP4 is more universally supported. Pick MKV for archival or anything with multiple subtitle and audio tracks; pick MP4 for sharing or streaming.
  • “AV1 is always better than H.264.” AV1 compresses much more efficiently — that’s true. Whether AV1 is “better” for you depends on whether the device you’re playing on has a hardware decoder. A 4K AV1 file is gorgeous on a recent flagship phone and unplayable on a 2019 budget Android. H.264 always plays.
  • “Higher bitrate equals better quality.” Only within the same codec, on the same content. A 5 Mbps H.265 stream usually looks better than a 5 Mbps H.264 stream because H.265 squeezes more out of every bit. Comparing bitrates across codecs is meaningless.
  • “Changing the file extension fixes playback.” Almost never. The bytes inside the file don’t change when you rename .mkv to .mp4, and most players read the header to identify the container regardless of the extension. The renamed file fails just as hard as the original.
  • “VLC plays everything, so codec doesn’t matter.” VLC software-decodes most codecs on the desktop, which makes it the go-to “did the file download right” tool. But the moment you need to edit, share, or play it on a phone or TV, codec compatibility comes back. VLC’s tolerance is a property of VLC, not the file.

Closing Thoughts

The container-versus-codec split is one of those small distinctions that explains an outsized fraction of video weirdness. Once you can look at a file and ask both “what’s the wrapper” and “what’s actually inside,” codec error messages stop being mysterious and the “plays on my computer but not on my phone” cases start making sense.

The rule of thumb hasn’t changed in fifteen years: MP4 with H.264 + AAC is the safest “ship it anywhere” combination. H.265 is the right upgrade if you know your target devices are recent. AV1 is the right bet if you’re optimizing for the next decade. If you want to skip the manual remux step and just save a streaming video as something everyone can play, VidMost defaults to MP4 + H.264 + AAC and handles the details for you.

Related reading

Frequently Asked Questions

What's the difference between a container and a codec?
A container is the file format that wraps everything — video tracks, audio tracks, subtitles, chapter markers, metadata. Common containers are MP4, MKV, WebM, MOV, and MPEG-TS. A codec is the algorithm that compresses or decompresses the actual audio and video data inside the container. Common video codecs are H.264, H.265, AV1, and VP9. You can think of the container as the box and the codec as the language the contents are written in. Different containers can hold the same codec, and the same container can hold different codecs.
Is MP4 a codec or a container?
MP4 is a container, not a codec. The `.mp4` extension refers to the ISO Base Media File Format (ISO/IEC 14496-14), which is a packaging format derived from Apple's QuickTime MOV. An MP4 file can hold H.264, H.265, AV1, or even MPEG-4 Part 2 video, paired with AAC, MP3, AC-3, or other audio codecs. When someone says "convert this to MP4," they almost always mean "put H.264 video and AAC audio into an MP4 container" — the most universally compatible combination.
Why won't my .mp4 file play even though MP4 is universal?
Because MP4 is just the wrapper. The real question is what codec the video inside uses. An MP4 file with AV1 video won't play in older versions of Safari, on Apple TV models before 2022, or on televisions that lack an AV1 hardware decoder — the container is fine, but the codec is unsupported. The same problem appears with H.265 on devices without HEVC support. Run the file through MediaInfo or `ffprobe` and check the actual codec inside before assuming the container is the issue.
Which is better: MP4 or MKV?
Neither is universally better — they serve different needs. MP4 is the more universally supported container: browsers, phones, smart TVs, and streaming services all speak it natively. MKV (Matroska) is more flexible: it supports more codec combinations, unlimited subtitle and audio tracks, chapter menus, and unusual features like ordered chapters. For sharing or streaming, pick MP4. For archival, ripping, or anything with multiple subtitle tracks, MKV is the better choice. The video quality is identical when the same codec is used in either container.
Should I use H.264, H.265, or AV1?
Use H.264 if you need maximum compatibility — every modern device decodes it in hardware. Use H.265 (HEVC) if you want roughly half the bitrate at the same quality and your target devices are post-2017. Use AV1 if you want the best compression efficiency available today and your audience uses recent browsers and 2022-or-later devices. AV1 encoding is still much slower than H.264, so it's a poor pick for real-time use. For most users who want a file that just works everywhere, H.264 in MP4 is still the right answer.
Why does my Apple TV play H.265 but not VP9?
Apple's video stack supports H.264 and H.265 because those are the codecs Apple invested in for the iTunes Store and Apple TV+. VP9 is Google's codec, used heavily by YouTube before AV1, and Apple never shipped VP9 hardware decoders on tvOS or iOS. Safari on macOS added VP9 software decoding relatively late, and many Apple TV models still cannot decode VP9 at all. This is why YouTube ships H.264 (and sometimes H.265 or AV1 on the newest devices) when you watch on an Apple device, but VP9 on Chrome for Windows.
Can I change a video's codec without re-encoding?
No. Changing the codec always requires decoding the existing video frames and re-encoding them with the new codec, which takes time and loses a small amount of quality. What you *can* do without re-encoding is change the container — this is called remuxing. Tools like `ffmpeg -c copy` move the same encoded streams from an MKV into an MP4, or from MPEG-TS segments into a single MP4, without touching the codec. Remuxing is fast and lossless; re-encoding is slow and lossy.
Is AV1 the future?
Probably, but it'll take years. AV1 offers around 30 percent better compression than H.265 at the same quality and is royalty-free, which makes it attractive to streaming services that don't want to pay HEVC licensing fees. YouTube, Netflix, and Twitch all ship AV1 to capable devices today. The catch is hardware support: AV1 hardware decoders are common on 2022-and-later phones, GPUs, and smart TVs, but older devices fall back to software decoding, which drains battery and chokes on 4K. Expect AV1 to dominate by the end of the decade, with H.264 hanging on as the universal fallback for another decade beyond that.