Intel GPU Hardware Transcoding Pipeline in FFmpeg

Configuring an end-to-end hardware-accelerated pipeline on Intel GPUs with FFmpeg eliminates costly memory transfers between the CPU (system RAM) and GPU (VRAM), maximizing throughput and reducing latency. This guide details how to configure FFmpeg to decode, scale, and encode video strictly inside Intel GPU memory using Intel Quick Sync Video (QSV) and VA-API.

The Complete Intel QSV Pipeline

Intel Quick Sync Video (QSV) is Intel's dedicated hardware core for media processing. To keep frames strictly in GPU memory from input to output, use the following command:

ffmpeg -hwaccel qsv -hwaccel_output_format qsv -c:v h264_qsv -i input.mp4 \
  -vf "vpp_qsv=w=1920:h=1080" \
  -c:v h264_qsv -b:v 5M -c:a copy output.mp4

Command Breakdown

  • -hwaccel qsv: Enables QSV hardware acceleration for the decoding process.
  • -hwaccel_output_format qsv: Forces the decoded frames to remain in GPU memory as QSV surfaces instead of being copied back to system RAM.
  • -c:v h264_qsv (before -i): Specifies the hardware-accelerated decoder (e.g., h264_qsv, hevc_qsv).
  • -vf "vpp_qsv=w=1920:h=1080": Applies Intel's Video Processing Pipeline (vpp_qsv) filter directly on the GPU surfaces to handle scaling, deinterlacing, or color space conversion.
  • -c:v h264_qsv (after -i): Specifies the hardware-accelerated encoder, which reads directly from the GPU surfaces emitted by the filter.
  • -c:a copy: Stream-copies the audio without re-encoding to save CPU cycles.

Alternative: Full Pipeline Using VA-API (Linux)

If you are running on Linux and prefer the open-source VA-API interface instead of QSV, use the following zero-copy pipeline:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
  -i input.mp4 \
  -vf "scale_vaapi=w=1920:h=1080" \
  -c:v h264_vaapi -b:v 5M -c:a copy output.mp4

VA-API Key Components

  • -hwaccel vaapi: Engages the VA-API hardware acceleration stack.
  • -hwaccel_device /dev/dri/renderD128: Selects the target Intel render node.
  • -hwaccel_output_format vaapi: Retains decoded frames inside VA-API video memory surfaces.
  • -vf "scale_vaapi=...": Executes the scaling operation inside the GPU execution units via VA-API.
  • -c:v h264_vaapi: Encodes the video directly from the VA-API surface.

Verifying Hardware Execution

To verify that the frames are not leaking into host memory:

  1. Check FFmpeg's startup logs. Look for surface allocation markers and confirm no hwdownload or hwupload filters are inserted automatically.
  2. Monitor GPU usage on Linux with intel_gpu_top (part of the igt-gpu-tools package) to ensure the Video (VDBOX) and VideoEnhance (VEBOX) engines show active workloads while CPU usage remains negligible.