How to Encode VP8 Video Using FFmpeg libvpx

This article provides a practical guide on how to transcode video files to the VP8 video format using FFmpeg and the libvpx encoder. You will learn how to configure essential encoding parameters, control output quality using constant quality (CRF) or variable bitrate (VBR) modes, and optimize encoding speed for web-ready WebM video distribution.

Basic VP8 Command Structure

To transcode a video to VP8, you typically package it in a WebM container (.webm). Because VP8 is a video-only codec, you should pair it with an audio codec like Vorbis (libvorbis) or Opus (libopus).

The most basic command looks like this:

ffmpeg -i input.mp4 -c:v libvpx -c:a libvorbis output.webm

For general use, Constant Rate Factor (CRF) is the recommended method. It ensures that every frame gets the exact amount of data it needs to maintain a consistent level of visual quality, regardless of motion or complexity.

To use CRF mode with VP8, you must set the video bitrate to 0 (-b:v 0) and define your desired quality level using the -crf flag.

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

Key Quality Settings for CRF:

Two-Pass Variable Bitrate (VBR) Mode

If you need your output file to fit a specific target size, you should use two-pass VBR. This method analyzes the video during the first pass and performs the actual encoding during the second pass to optimize the target bitrate.

Run these two commands sequentially:

Pass 1:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -speed 4 -pass 1 -an -f null /dev/null

Pass 2:

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

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

Key VBR Settings:

Optimizing Speed and Performance

VP8 encoding can be slow. You can control the balance between encoding speed and compression efficiency using the -quality (or -deadline) and -cpu-used flags.

ffmpeg -i input.mp4 -c:v libvpx -crf 15 -b:v 0 -quality good -cpu-used 2 -c:a libopus output.webm