Back to feed
Dev.to
Dev.to
6/17/2026
How to Encode Video with H.264 (libx264) Using FFmpeg

How to Encode Video with H.264 (libx264) Using FFmpeg

Short summary

H.264/libx264 is the standard codec for web and mobile video delivery. CRF controls quality on a 0-51 scale (default 23); increase it for smaller files, decrease for higher quality. Presets balance encoding speed and compression efficiency—slower presets produce smaller files at the same quality level, making them suitable for content served repeatedly.

  • CRF 23 is the default for general web video; CRF 18-20 for high quality, CRF 26-28 for smaller files
  • Presets (fast/medium/slow) control encoding time and efficiency, not visual quality; choose based on pipeline constraints
  • Every +6 CRF approximately halves file size; avoid CRF >30 for user-facing content due to visible artifacts

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Explore more