How to Use transpose_vaapi Filter in FFmpeg
This article explains how to use the transpose_vaapi
filter in FFmpeg to perform hardware-accelerated video rotation and
flipping. Using the Video Acceleration API (VA-API) offloads the video
processing workload from your CPU to a compatible GPU (such as Intel or
AMD), resulting in significantly faster render times and lower CPU
utilization. You will learn the correct command-line syntax, available
direction parameters, and a practical example to get started.
Prerequisites
To use VA-API hardware acceleration, your system must have: * A
VA-API-compatible GPU (Intel HD/UHD/Iris Graphics or AMD Radeon). * The
necessary VA-API drivers installed on your operating system (typically
Linux). * A build of FFmpeg configured with --enable-vaapi
and --enable-filter=transpose_vaapi.
The
transpose_vaapi Syntax and Parameters
The transpose_vaapi filter accepts a dir
parameter to define how the video should be rotated or flipped.
The direction values can be specified as integers or named constants:
0orcclock_flip: Rotate 90 degrees counter-clockwise and flip vertically.1orclock: Rotate 90 degrees clockwise.2orcclock: Rotate 90 degrees counter-clockwise.3orclock_flip: Rotate 90 degrees clockwise and flip vertically.
Command Example
To use this filter, you must initialize the VA-API hardware device,
decode the video into GPU memory, apply the filter, and then encode the
video using a VA-API encoder (such as h264_vaapi or
hevc_vaapi).
Here is a standard command to rotate a video 90 degrees clockwise:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i input.mp4 -vf "transpose_vaapi=dir=clock" -c:v h264_vaapi output.mp4Command Breakdown
-hwaccel vaapi: Enables VA-API hardware acceleration for decoding.-hwaccel_device /dev/dri/renderD128: Specifies the path to the GPU render node.-hwaccel_output_format vaapi: Keeps the decoded video frames in GPU memory (surface format) to avoid copying data back and forth to system RAM.-i input.mp4: Defines the input video.-vf "transpose_vaapi=dir=clock": Applies the VA-API transpose filter. Usingclock(or1) rotates the video 90 degrees clockwise.-c:v h264_vaapi: Uses the hardware-accelerated H.264 encoder to encode the output video directly on the GPU.output.mp4: The output file name.