Transcode HEVC with Hardware Acceleration in FFmpeg

This guide explains how to transcode video files using HEVC (H.265) hardware-accelerated decoding in FFmpeg on Windows. By offloading the decoding process to your graphics card (GPU), you can drastically reduce CPU utilization and speed up transcoding times. You will find step-by-step instructions and command examples for NVIDIA, Intel, and AMD hardware, as well as universal Windows APIs.

Prerequisites

Before starting, ensure you have the following: * A graphics card that supports HEVC hardware decoding (NVIDIA GeForce GTX 960 or newer, Intel HD Graphics 530 or newer, AMD Radeon RX 400 series or newer). * The latest GPU drivers installed on Windows. * The latest version of FFmpeg installed and added to your system’s PATH.


Method 1: NVIDIA GPUs (CUDA / NVDEC)

NVIDIA GPUs use NVDEC for hardware decoding. This is the most efficient method for NVIDIA hardware because it keeps the video frames in GPU memory during the transcoding process.

To decode HEVC with CUDA and transcode it to H.264 using NVENC, run:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input_hevc.mp4 -c:v h264_nvenc -preset fast output.mp4

To decode HEVC with CUDA and transcode it back to HEVC (H.265) to reduce file size:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input_hevc.mp4 -c:v hevc_nvenc -preset fast output.mp4

Command Breakdown: * -hwaccel cuda: Enables CUDA hardware acceleration for decoding. * -hwaccel_output_format cuda: Keeps decoded frames in GPU memory to prevent bottlenecking. * -i input_hevc.mp4: Specifies the input HEVC file. * -c:v h264_nvenc or hevc_nvenc: Selects the hardware-accelerated encoder.


Method 2: Intel GPUs (Quick Sync Video - QSV)

If your Windows PC uses Intel Integrated Graphics, you can use Quick Sync Video (QSV) for hardware-accelerated decoding and encoding.

To decode HEVC and transcode to H.264 using QSV:

ffmpeg -hwaccel qsv -c:v hevc_qsv -i input_hevc.mp4 -c:v h264_qsv -preset fast output.mp4

Command Breakdown: * -hwaccel qsv: Enables Quick Sync hardware acceleration. * -c:v hevc_qsv: Explicitly tells FFmpeg to use the Intel QSV HEVC decoder. * -c:v h264_qsv: Encodes the output to H.264 using QSV.


Method 3: Universal Windows (D3D11VA / DXVA2)

If you have an AMD GPU, or want a universal method that works across AMD, Intel, and NVIDIA on Windows, use Direct3D11 Video Acceleration (D3D11VA).

To decode HEVC using D3D11VA and transcode to H.264:

ffmpeg -hwaccel d3d11va -i input_hevc.mp4 -c:v libx264 -crf 20 output.mp4

To transcode using AMD’s hardware encoder (AMF) alongside D3D11VA decoding:

ffmpeg -hwaccel d3d11va -i input_hevc.mp4 -c:v h264_amf output.mp4

Command Breakdown: * -hwaccel d3d11va: Utilizes the Windows Direct3D11 API for hardware decoding. * -c:v h264_amf: Uses AMD’s Advanced Media Framework encoder.


Verifying Hardware Acceleration

To verify that your GPU is actually performing the work during transcoding: 1. Open the Windows Task Manager (Ctrl + Shift + Esc). 2. Go to the Performance tab. 3. Click on your GPU. 4. Look at the Video Decode and Video Encode graphs. If hardware decoding is working correctly, you will see activity on the Video Decode graph.