How to Encode VP8 Video with FFmpeg and libvpx

This guide provides a straightforward tutorial on how to encode video files to the VP8 format using FFmpeg and the libvpx encoder library. You will learn the essential command-line syntax, recommended settings for bitrate and quality control, and how to perform both constant quality and two-pass encoding for optimal WebM delivery.

Basic VP8 Encoding Command

To encode a video to VP8, you need to output to a container that supports it, typically WebM (.webm). VP8 video is usually paired with either Vorbis or Opus audio.

Here is the basic command to convert a video using standard settings:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -c:a libvorbis -b:a 128k output.webm

For the best balance of quality and file size, use Constant Rate Factor (CRF) mode. Unlike other encoders, libvpx requires both the -crf limit and the -b:v limit to be enabled together. Setting -b:v 0 tells FFmpeg to use pure CRF mode.

The CRF scale for VP8 ranges from 4 (best quality) to 63 (worst quality). Recommended values are usually between 10 and 35.

ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 0 -c:a libopus -b:a 128k output.webm

Two-Pass Encoding for Target File Sizes

If you need your output file to be an exact size or fit within strict bandwidth limits, two-pass encoding is highly recommended. This process analyzes the video on the first pass and performs the actual encoding on the second pass.

Pass 1:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -quality good -cpu-used 4 -an -pass 1 -f webm /dev/null

Pass 2:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -quality good -cpu-used 1 -c:a libvorbis -b:a 128k -pass 2 output.webm

(Note: Windows users should replace /dev/null in the first pass with NUL.)

Key Parameters Explained: