C.W.K.
Stream
Lesson 04 of 10 · published

Container vs Codec — the Distinction Most People Miss

~12 min · container, codec, muxing

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

The box and the thing inside the box

Every media file on your disk has two layers. The outer layer is the container (sometimes called format): MP4, MKV, MOV, WebM, MXF, AVI, FLV. The inner layer is the codec: H.264, H.265 (HEVC), AV1, ProRes, VP9 for video; AAC, MP3, Opus, FLAC, AC-3 for audio. The container's job is to interleave streams and store timing, metadata, and chapter markers. The codec's job is to compress and decompress the actual pixels and samples.

This is the single distinction that, once internalized, makes every FFmpeg error message readable. "Codec not currently supported in container" stops being mysterious — it means you tried to stuff an H.265 video into an AVI container, which legally can't carry it.

Which containers carry which codecs

Some containers are fussy (AVI, FLV are old and limited). Others are permissive (MKV will hold almost anything; MP4 is the modern lingua franca for H.264/H.265/AV1 video plus AAC/Opus audio). When in doubt:

  • MP4 — the safe default. Plays everywhere. Holds H.264/H.265/AV1 video + AAC/Opus audio.
  • MKV — ultra-flexible. Holds anything, including multiple subtitle tracks and chapter markers. Not always supported by hardware players.
  • MOV — Apple's variant of MP4. Use this when the workflow is QuickTime/Final Cut. ProRes lives here.
  • WebM — VP9/AV1 video + Vorbis/Opus audio. Web streaming.

Code

Inspect the container vs the codec·bash
# What the container is
ffprobe -v error -show_entries format=format_name,format_long_name input.mp4

# What the streams (codecs) inside are
ffprobe -v error -show_entries stream=codec_name,codec_long_name,codec_type input.mp4

# Sample output:
# stream|codec_name=h264
# stream|codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
# stream|codec_type=video
# stream|codec_name=aac
# stream|codec_long_name=AAC (Advanced Audio Coding)
# stream|codec_type=audio
Container-only change vs codec change·bash
# Same codecs, different container — fast (no re-encode)
# This is called REMUXING. Track 2 has a whole lesson on this.
ffmpeg -i input.mkv -c copy output.mp4

# Different codec — slow (re-encode video and audio)
# This is called TRANSCODING.
ffmpeg -i input.mp4 -c:v libx265 -c:a libopus output.mkv

External links

Exercise

Find one MP4, one MOV, and one MKV file on your machine. For each, run ffprobe -v error -show_entries format=format_name -show_entries stream=codec_name,codec_type. Note: do MP4 and MOV share codecs? Does MKV hold something MP4 can't? Write your three findings down before moving on.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.