What are the best FFmpeg settings for WebM?

Optimizing WebM video generation requires a careful balance between file size, visual quality, and encoding speed. This guide details the ideal command-line configurations for FFmpeg using the modern VP9 video codec and Opus audio codec. By utilizing two-pass constrained quality encoding, creators can achieve highly efficient files optimized specifically for web delivery and browser compatibility without suffering massive quality drops.

The Optimal Two-Pass Commmand Line

The recommended approach for encoding web-ready WebM videos is to use a two-pass Constrained Quality (CQ) configuration. This method guarantees excellent visual preservation during high-motion scenes while keeping the file size compact for simpler scenes.

Run the following two commands sequentially in your terminal:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -crf 28 -quality good -speed 4 -tile-columns 2 -row-mt 1 -an -f null /dev/null && \
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -crf 28 -quality good -speed 1 -tile-columns 2 -row-mt 1 -c:a libopus -b:a 128k output.webm

Breakdown of Core Settings

Understanding the individual arguments helps in customizing the output to suit specific file requirements:

Maximizing Multi-Core CPU Performance

The native libvpx-vp9 encoder does not automatically utilize all available processor cores efficiently. The inclusion of multi-threading flags avoids bottlenecking the system CPU:

Audio Optimization