Admin

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

A container such as MP4, MKV or MOV is the box: a file format that bundles video, audio and subtitle tracks with timing and metadata. A codec such as H.264, H.265 (HEVC) or AV1 is the method that compresses the picture or sound inside that box. So "MP4 vs H.264" is not a choice between rivals, because a typical .mp4 file contains H.264 video. When a file refuses to play, the player can usually open the box but has no decoder for the codec inside.

Diagram of a video file as a container box (.mp4, .mkv or .mov) holding four tracks: a video track compressed with H.264, H.265 or AV1, an audio track compressed with AAC or Opus, a text or image subtitle track, and metadata such as title and chapters, which needs no codec
Figure 1. The container is the box and the file format; each track inside it is compressed by its own codec, and the player needs a decoder for every one.

Container vs codec: the box and what is packed inside

Think of a parcel holding sealed packets. The container defines the parcel: how tracks are stored, kept in sync and labelled. Each packet was compressed by a codec (short for coder-decoder), and the player needs the matching decoder to open it. A typical video file holds:

  • Video track: usually one, compressed with H.264, H.265, VP9 or AV1.
  • Audio tracks: one or more, for example AAC or Opus; a movie may carry several languages.
  • Subtitle tracks: text or image-based subtitles that can be switched on and off.
  • Metadata: title, duration, chapters, rotation and sync timing.

The file extension names only the box. MP4 is MPEG-4 Part 14 (ISO/IEC 14496-14), a descendant of Apple's QuickTime format, which lives on as .mov. MKV is Matroska, an open container published as IETF RFC 9559 in 2024; WebM is a web-oriented version of Matroska.

MP4 vs MKV vs MOV: what changes and what doesn't

The codec decides picture quality, so the same H.264 stream looks identical whether it sits in an MP4 or an MKV file. What differs is what the box can hold and which devices will open it.

  • MP4: the most widely supported container. Browsers, phones, TVs, editing apps and upload sites accept it, typically with H.264, H.265 or AV1 video and AAC audio. Subtitle options are limited to a few text formats.
  • MKV: takes almost any codec, plus many audio and subtitle tracks (including styled ASS and image-based PGS subtitles), chapters and attachments such as fonts. It suits archives and home media servers, but support in browsers, phones and editors is patchy.
  • MOV: Apple's QuickTime container, used for iPhone videos and professional editing. It is a close relative of MP4; the codec inside still decides what plays.

H.264 vs H.265 vs AV1: how the codecs compare

Each codec generation fits the same picture into fewer bits by doing more computation. MPEG-2 video (ITU-T H.262, 1995) powered DVDs and early digital TV. H.264, also called AVC, was first published by the ITU in 2003 and remains the safe default. H.265 (HEVC) followed in 2013, and the ITU announced it as needing only half the bit rate of H.264. AV1, released by the Alliance for Open Media in 2018, is royalty-free and, according to MDN, compresses better than both HEVC and Google's VP9.

CodecFirst publishedBitrate vs H.264 at similar qualityPlayback supportLicensing
H.264 (AVC)2003, ITU-T and ISO/IECBaselineAlmost every browser, phone, TV and PCPatent pool (Via LA)
H.265 (HEVC)2013, ITU-T and ISO/IECAbout half (ITU's headline figure)Apple devices, UHD Blu-ray, many 4K TVs; browsers and Windows depend on hardware or add-onsSeveral patent pools
VP92013, GoogleSimilar to HEVCMost web browsersRoyalty-free
AV12018, Alliance for Open MediaUp to about halfCurrent browsers; on Apple, only devices with an AV1 hardware decoderRoyalty-free

Treat "half" as a headline figure: real savings vary with content, resolution and encoder settings, and tend to be largest on high-resolution video. Newer codecs also need more processing to encode, and smooth playback on phones and laptops usually needs a hardware decoder.

Timeline of video codecs: MPEG-2 in 1995, H.264 (AVC) in 2003, VP9 and H.265 (HEVC) in 2013, and AV1 in 2018, with MPEG-2 marked as legacy, H.264 and H.265 as licensed through patent pools, and VP9 and AV1 as royalty-free
Figure 2. Each generation fits similar quality into fewer bits. H.264 and H.265 are licensed through patent pools; VP9 and AV1 are royalty-free.

Why a video won't play even though it is an MP4

A player checks three things in order: can it read the container, does it have a decoder for the video codec, and does it have one for the audio codec. Failing the second or third check explains the classic symptoms: an error on a normal-looking .mp4, sound over a black screen, or a picture with no sound.

Flowchart of the three checks a player makes: can it read the container, can it decode the video codec, can it decode the audio codec; failing each step gives an unsupported-file error, an error or sound without picture, or picture without sound
Figure 3. A file with a familiar extension can still fail at the codec checks, which explains sound with a black screen or picture with no sound.

Common real-world cases:

  • iPhone video on a Windows PC. With Settings > Camera > Formats set to High Efficiency, iPhones record HEVC. Windows' built-in apps need the HEVC Video Extensions (preinstalled on some PCs, otherwise from the Microsoft Store). Choosing Most Compatible records H.264 instead, and Apple notes that AirDrop, Messages or email may send H.264 automatically when the receiving device can't handle HEVC.
  • AV1 on older Apple devices. Safari plays AV1 only where there is a hardware decoder, such as M3 Macs and later, iPhone 15 Pro and iPhone 16 and later.
  • MKV files ripped from discs. The video may be fine while a surround-sound audio track uses a format the TV or phone can't decode, so playback is silent.

To diagnose a stubborn file:

  1. Check the codecs, not the extension: in VLC open Tools > Codec Information, or use MediaInfo or ffprobe.
  2. Try VLC, which ships with its own decoders. If the file plays there, it is intact and the original player lacks a codec.
  3. Add the missing decoder, or convert a copy; H.264 with AAC audio in MP4 is the safest target.

Renaming .mkv to .mp4 doesn't convert it: remux vs transcode

Changing the extension only changes the label; the bytes inside stay the same. To change the box, remux. To change what is inside the box, transcode.

  • Remux (stream copy) moves the compressed tracks into a new container without decoding them. FFmpeg's documentation notes that skipping decoding and encoding makes this very fast and lossless. Example: ffmpeg -i input.mkv -c copy output.mp4. It works only when the new container supports every track: H.264 video and AAC audio move from MKV to MP4 easily, but ASS or PGS subtitles must be dropped or converted.
  • Transcode decodes every frame and encodes it again, which is the only way to change the codec, resolution or bitrate. It is slow, and with lossy codecs each new generation discards a little more detail. Example: ffmpeg -i input.mov -c:v libx264 -c:a aac output.mp4.
Decision chart comparing remux and transcode: renaming the extension changes nothing; if the new container supports the existing codecs, remux with stream copy, which is fast and lossless; otherwise transcode, which decodes and re-encodes, is slow and loses some quality
Figure 4. Remuxing changes only the box and keeps quality identical; transcoding changes the contents and costs time and some quality.

Export settings: sharing vs archiving

Pick the codec for the people who will watch, and the container for what the file has to carry.

GoalContainerVideo codecAudioWhy
Share with anyone (chat apps, email, older PCs, TVs)MP4H.264AACPlays almost everywhere; files are larger
Your own phone or 4K libraryMP4 or MOVH.265AACSimilar quality in less space; keep an H.264 copy for others
Video on a websiteMP4 or WebMAV1 with an H.264 fallbackAAC (MP4) or Opus (WebM)Smallest files where AV1 decoding exists
Archive or master copyOriginal file, or MKVKeep the originalKeep the originalRemux, don't re-encode; MKV holds many tracks

Whatever you pick, keep the original file and export from it instead of re-encoding compressed copies again and again.

FAQ

Is MKV better quality than MP4?

No. The same H.264 or HEVC stream looks identical in MKV and MP4; MKV simply holds more kinds of tracks, while MP4 plays on more devices.

Are H.265 and HEVC the same thing?

Yes. ITU-T H.265 and ISO/IEC 23008-2 (MPEG-H Part 2) are the same standard, High Efficiency Video Coding. Likewise H.264 is AVC, also published as MPEG-4 Part 10. Don't confuse that with MP4, which is MPEG-4 Part 14: the container, not the codec.

Should I convert my H.264 videos to H.265 to save space?

Only if storage matters more than time and a small quality loss. Transcoding never improves quality, takes a long time for a large library, and older devices may not play the results. Keep the originals until you have checked the copies.

Sources: ITU press release: H.265/HEVC video coding standard (2013); MDN Web Docs: Web video codec guide; FFmpeg documentation: stream copy and transcoding; Apple Support: Using HEIF or HEVC media on Apple devices

Related reading

Original illustrations created to help explain this article.