DEV Community

Javid Jamae
Javid Jamae

Posted on • Originally published at ffmpeg-micro.com

How to Encode VP9 Video with FFmpeg: libvpx-vp9 CRF, Bitrate, and Quality Guide

Originally published at ffmpeg-micro.com

VP9 is Google's open, royalty-free video codec. It powers most of YouTube's streaming library, and every modern browser supports it through the WebM container. If you need high-quality web video without licensing headaches, VP9 with FFmpeg's libvpx-vp9 encoder is the standard choice.

This guide covers the practical settings: CRF mode, 2-pass encoding, speed tuning, and multithreading.

TL;DR: The Default VP9 Command

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 31 -b:v 0 -c:a libopus -b:a 128k output.webm
Enter fullscreen mode Exit fullscreen mode

CRF 31 with -b:v 0 gives you true constant-quality mode. Opus audio at 128k is the natural pairing for WebM.

What CRF Does in VP9

VP9's CRF scale runs from 0 to 63. Lower means better quality and bigger files. This is different from H.264's libx264, which uses a 0-51 range.

You must set -b:v 0 for true CRF mode. If you leave out -b:v 0, FFmpeg treats the CRF value as a constrained quality floor. This is the single most common VP9 encoding mistake.

VP9 CRF Values by Use Case

CRF Use Case Notes
15-20 Archival / master copies Near-lossless. Large files.
24-28 High-quality streaming Visually transparent for most content
30-33 General web video Good quality at reasonable file sizes
36-42 Low-bandwidth delivery Noticeable softness, but watchable
45+ Previews / thumbnails Significant quality loss

Speed Settings

-cpu-used is a number from 0 to 8. Zero is the slowest and highest quality. For most encodes, -deadline good -cpu-used 2 is the sweet spot.

2-Pass Encoding

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -deadline good -cpu-used 2 -row-mt 1 -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -deadline good -cpu-used 2 -row-mt 1 -pass 2 -c:a libopus -b:a 128k output.webm
Enter fullscreen mode Exit fullscreen mode

Multithreading

Always enable -row-mt 1. It can cut encode time by 50% or more with no quality penalty.

Common Pitfalls

  • Forgetting -b:v 0 in CRF mode
  • Using -cpu-used 0 (extremely slow)
  • Skipping -row-mt 1
  • Using .mp4 container (use .webm instead)

Read the full guide with API examples at ffmpeg-micro.com/blog/ffmpeg-vp9-encoding-libvpx-guide

Top comments (0)