How to Use the vp9_qsv Encoder in FFmpeg

Transcoding video using Intel’s Quick Sync Video (QSV) hardware acceleration can drastically speed up your encoding workflow while reducing CPU usage. This article provides a straightforward guide on how to transcode videos to the VP9 format using the hardware-accelerated vp9_qsv encoder in FFmpeg, covering system prerequisites, basic command-line syntax, and advanced configuration options for optimal quality and performance.

Prerequisites

To use the vp9_qsv encoder, your system must meet the following requirements: * Hardware: An Intel processor supporting VP9 hardware encoding (Intel Kaby Lake / 7th Gen Core processors or newer). * Drivers: Installed Intel Graphics Drivers (Windows) or Intel Media Driver / oneVPL (Linux). * FFmpeg Build: A version of FFmpeg compiled with QSV support (--enable-libmfx or --enable-libvpl).

You can verify if your FFmpeg installation supports the encoder by running:

ffmpeg -encoders | grep vp9_qsv

Basic Transcoding Command

To transcode a standard video file to VP9 using hardware-accelerated encoding, use the following basic syntax:

ffmpeg -i input.mp4 -c:v vp9_qsv -c:a copy output.mkv

In this command: * -i input.mp4 specifies the input file. * -c:v vp9_qsv selects the Intel QSV VP9 encoder for the video stream. * -c:a copy copies the audio stream without re-encoding to save time and preserve quality.


Full Hardware Acceleration Pipeline

For maximum performance, you can decode the input video in hardware as well as encode it. This prevents bottlenecking by keeping the video frames entirely in GPU memory.

If your input video is H.264, use the following command:

ffmpeg -hwaccel qsv -c:v h264_qsv -i input.mp4 -c:v vp9_qsv -c:a copy output.mkv

Note: Replace h264_qsv with hevc_qsv if your source file is encoded in HEVC/H.265.


Controlling Quality and Bitrate

Like other QSV encoders, vp9_qsv supports several rate control methods to balance file size and visual quality.

1. Target Bitrate (VBR)

To target a specific average bitrate, use the -b:v flag:

ffmpeg -i input.mp4 -c:v vp9_qsv -b:v 5M output.mkv

2. Intelligent Constant Quality (ICQ)

ICQ is the recommended mode for QSV when you want a constant quality level across the video while allowing the bitrate to fluctuate dynamically. Lower values yield higher quality.

ffmpeg -i input.mp4 -c:v vp9_qsv -global_quality 25 output.mkv

Useful range for -global_quality is typically between 20 (high quality, larger file) and 32 (lower quality, smaller file).

3. Fixed QP (Constant QP)

For strict quality control per frame without dynamic optimizations, use the -q flag:

ffmpeg -i input.mp4 -c:v vp9_qsv -q 24 output.mkv