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

Codecs vs Encoders — Same Word, Different Thing

~10 min · codec, encoder, decoder, h264

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

The vocabulary trap

People say 'H.264' to mean three different things: the codec specification, an encoder that produces H.264 bitstreams, and a decoder that reads them. FFmpeg keeps these separate, and once you internalize the difference, error messages become much friendlier.

  • Codec — the format specification (H.264, H.265, AV1). Defined by a standards body. Doesn't 'do' anything; it's a document.
  • Encoder — software that produces bytes conforming to a codec spec. Multiple encoders can target the same codec: libx264 (CPU), h264_videotoolbox (Apple Silicon hardware), h264_nvenc (NVIDIA), h264_amf (AMD), h264_qsv (Intel) all produce H.264.
  • Decoder — software that reads bitstream bytes and produces raw frames. Usually one per codec, sometimes accelerated.

Why this matters

Different encoders for the same codec have wildly different speed/quality tradeoffs. libx264 at -preset slow often beats hardware encoders on quality at the same bitrate; hardware encoders crush them on speed. You pick based on the workflow.

Code

List encoders/decoders for a specific codec·bash
# All H.264 encoders this build supports
ffmpeg -hide_banner -encoders 2>/dev/null | grep -i 264
# V..... libx264              libx264 H.264 / AVC / MPEG-4 AVC
# V....D h264_videotoolbox    VideoToolbox H.264 Encoder (Apple Silicon)
# V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder (Linux)

# All H.264 decoders
ffmpeg -hide_banner -decoders 2>/dev/null | grep -i 264

# Same trick for HEVC, AV1
ffmpeg -hide_banner -encoders 2>/dev/null | grep -iE 'hevc|265'
ffmpeg -hide_banner -encoders 2>/dev/null | grep -iE 'av1'
Pick the encoder that matches the workflow·bash
# CPU (best quality, slow): libx264
ffmpeg -i in.mp4 -c:v libx264 -preset slow -crf 20 out_cpu.mp4

# Hardware on Apple Silicon (5x faster, 'good enough' for daily uploads)
ffmpeg -i in.mp4 -c:v h264_videotoolbox -b:v 8M out_hw.mp4

# NVIDIA (Linux/Windows with an RTX/Quadro GPU)
ffmpeg -i in.mp4 -c:v h264_nvenc -preset p5 -cq 22 out_nv.mp4

External links

Exercise

On your machine, list the H.264 encoders (ffmpeg -encoders | grep 264) and the H.265/HEVC encoders. Run two encodes of the same source clip — one with libx264 -preset slow -crf 20, one with the hardware H.264 encoder for your platform — and compare wall-clock time and output file size. Which trades you'd actually take in your real workflow?

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.