Configure FFmpeg scale_cuda Scaling Algorithm
This article explains how to configure the scaling algorithm when
using the hardware-accelerated scale_cuda filter in FFmpeg.
You will learn about the available interpolation algorithms—such as
nearest neighbor, bilinear, and bicubic—and how to implement them in
your command-line workflows to balance video quality and GPU
performance.
The scale_cuda filter in FFmpeg utilizes NVIDIA GPU
hardware to resize video frames. To change the scaling algorithm (the
mathematical method used to resize the pixels), you must configure the
interp parameter inside the filter.
Supported Scaling Algorithms
The scale_cuda filter supports several interpolation
methods through the interp option:
nearest: Nearest-neighbor interpolation. It is the fastest method but produces blocky, pixelated results.bilinear: Bilinear interpolation. This is the default setting, offering a good balance between speed and quality, though it can look slightly soft.bicubic: Bicubic interpolation. This delivers sharper images and better quality than bilinear, making it ideal for most upscaling and downscaling tasks.lanczos: Lanczos resampling. It provides high-quality, sharp results with minimal aliasing, but requires more processing power.
Command-Line Examples
To apply these algorithms, specify the interp parameter
within your filter chain. For optimal performance, combine
scale_cuda with hardware-accelerated decoding
(-hwaccel cuda) and encoding (h264_nvenc or
hevc_nvenc).
1. Using Bicubic Scaling (Recommended for High Quality)
To scale a video to 1080p using the high-quality bicubic algorithm:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf "scale_cuda=1920:1080:interp=bicubic" -c:v h264_nvenc output.mp42. Using Bilinear Scaling (Recommended for Speed)
To scale a video to 720p using the faster bilinear algorithm:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf "scale_cuda=1280:720:interp=bilinear" -c:v h264_nvenc output.mp43. Using Lanczos Scaling (Recommended for Maximum Sharpness)
To scale a video to 4K using the lanczos algorithm:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf "scale_cuda=3840:2160:interp=lanczos" -c:v h264_nvenc output.mp4Key Considerations
- Pipeline Efficiency: Always use
-hwaccel cuda -hwaccel_output_format cudabefore the input file. This ensures the video is decoded directly into GPU memory, scaled on the GPU viascale_cuda, and passed directly to the NVENC encoder without copying frames back to system RAM. - Default Behavior: If you do not specify the
interpparameter, FFmpeg defaults tobilinear.