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).

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.mp4

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.mp4

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.mp4

Key Considerations

  • Pipeline Efficiency: Always use -hwaccel cuda -hwaccel_output_format cuda before the input file. This ensures the video is decoded directly into GPU memory, scaled on the GPU via scale_cuda, and passed directly to the NVENC encoder without copying frames back to system RAM.
  • Default Behavior: If you do not specify the interp parameter, FFmpeg defaults to bilinear.