Transcode Video with HEVC QSV in FFmpeg

This article provides a quick and practical guide on how to leverage Intel Quick Sync Video (QSV) hardware acceleration to transcode videos to the HEVC (H.265) format using FFmpeg. You will learn the basic command syntax, key parameters for controlling quality and speed, and how to configure your command for optimal hardware-accelerated performance.

To transcode a video using Intel’s hardware-accelerated HEVC encoder (hevc_qsv), your system must have an Intel processor that supports Quick Sync Video (Skylake generation or newer for HEVC encoding), up-to-date graphics drivers, and a version of FFmpeg compiled with QSV support (configured with --enable-libmfx or --enable-libvpl).

Basic Transcoding Command

To perform a basic transcode using hardware acceleration for both decoding and encoding, use the following command structure:

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

Controlling Quality and Bitrate

Using the default settings may not yield the best balance between file size and quality. You can control the output using different rate control methods:

1. Intelligent Constant Quality (ICQ)

ICQ is the recommended rate control method for QSV. It acts like CRF (Constant Rate Factor) in software encoders, adjusting bitrate to maintain a consistent quality level. Lower values result in better quality and larger file sizes.

ffmpeg -hwaccel qsv -i input.mp4 -c:v hevc_qsv -global_quality 20 output.mp4

2. Variable Bitrate (VBR)

If you need to target a specific average bitrate while allowing spikes for complex scenes, use VBR:

ffmpeg -hwaccel qsv -i input.mp4 -c:v hevc_qsv -b:v 5M -maxrate 8M output.mp4

Preset and Speed Settings

You can adjust the encoding speed and compression efficiency trade-off using the -preset option. QSV supports presets ranging from 1 (best quality, slowest) to 7 (fastest, lowest quality). The default preset is 4 (medium).

ffmpeg -hwaccel qsv -i input.mp4 -c:v hevc_qsv -preset 2 -global_quality 20 output.mp4

Verifying QSV Support

If you encounter errors, verify that your FFmpeg build supports the QSV HEVC encoder by running the following command in your terminal:

ffmpeg -encoders | grep qsv

Look for hevc_qsv in the output list. If it is missing, you will need to reinstall or recompile FFmpeg with Intel QSV enablement.