Configure Scaling Algorithm in FFmpeg scale_cuda

This guide demonstrates how to configure scaling and interpolation algorithms when using the hardware-accelerated scale_cuda filter in FFmpeg. By leveraging the interp_algo parameter, you can adjust output image sharpness and scaling quality using algorithms such as nearest neighbor, bilinear, bicubic, or Lanczos directly on NVIDIA GPUs.

The interp_algo Option

The scale_cuda filter controls its interpolation method through the interp_algo option. If left unspecified, FFmpeg defaults to bilinear.

The supported algorithm values are:

  • nearest: Nearest neighbor interpolation. Fastest processing speed with the lowest visual quality; best for pixel art or low-resource testing.
  • bilinear: Bilinear interpolation. Balanced performance and acceptable quality; suitable for fast encoding pipelines.
  • bicubic: Bicubic interpolation. Produces smoother transitions and better clarity than bilinear; ideal for general upscaling and downscaling.
  • lanczos: Lanczos resampling. Delivers the highest sharpness and detail preservation at the expense of higher GPU compute load.

Syntax and Filter Usage

The basic syntax assigns your chosen algorithm directly to interp_algo inside the filter chain:

scale_cuda=w=WIDTH:h=HEIGHT:interp_algo=ALGORITHM

You can also use positional arguments:

scale_cuda=1920:1080:interp_algo=bicubic

Complete Command Examples

1. Full GPU Pipeline with Bicubic Scaling

To keep video frames in GPU memory from decode to encode, combine CUDA hardware acceleration with scale_cuda:

ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
-vf "scale_cuda=1920:1080:interp_algo=bicubic" \
-c:v h264_nvenc -preset p4 -c:a copy output.mp4

2. CPU Decoding with Lanczos Scaling

If the input file is decoded on the CPU, upload the frames to GPU memory using hwupload_cuda before applying the scaling algorithm:

ffmpeg -i input.mp4 \
-vf "hwupload_cuda,scale_cuda=1280:720:interp_algo=lanczos" \
-c:v hevc_nvenc output.mp4

Choosing the Right Algorithm

  • For real-time streaming and high-framerate transcode sessions, choose bilinear to minimize GPU latency.
  • For standard offline video encoding where quality is prioritized, choose bicubic or lanczos to avoid ringing artifacts and preserve fine edges during resolution changes.