Scale (resize) and convert (pixel format) the input video, using accelerated CUDA kernels. Setting the output width and height works in the same way as for the scale filter.
The filter accepts the following options:
- w, h
-
Set the output video dimension expression. Default value is the input dimension.
Allows for the same expressions as the scale filter.
- interp_algo
-
Sets the algorithm used for scaling:
- nearest
-
Nearest neighbour
Used by default if input parameters match the desired output.
- bilinear
-
Bilinear
- bicubic
-
Bicubic
This is the default.
- lanczos
-
High-quality separable Lanczos (windowed sinc). The filter radius can be set with param; the default is 3.
- format
-
Controls the output pixel format. By default, or if none is specified, the input pixel format is used.
Converting between
yuv420p,yuv422p,yuv444p,yuv420p10,yuv422p10,yuv444p10,nv12,nv16,p010orp210andbgra,rgba,bgr0orrgb0is supported, also together with resizing. Resizing is then done on the RGB side, after converting from YUV or before converting to YUV, and always uses the generic filters selected with interp_algo. Resizing the YUV side in a separate instance instead needs less intermediate memory and may be faster, but filters chroma differently. YUV to RGB conversion uses the YCbCr matrix and range of the input, RGB to YUV conversion those selected for the output (see out_color_matrix and out_range). An unspecified matrix is treated as BT.601 and an unspecified range as limited. The conversion samples chroma independently of interp_algo: YUV to RGB conversion uses the nearest chroma sample, RGB to YUV conversion averages, which centers the chroma samples. - passthrough
-
If set to 0, every frame is processed, even if no conversion is necessary. This mode can be useful to use the filter as a buffer for a downstream frame-consumer that exhausts the limited decoder frame pool.
If set to 1, frames are passed through as-is if they match the desired output parameters. This is the default behaviour.
- use_filters
-
If set to 1, filter with a generic weight LUT instead of using fixed-function shader kernels. May be faster or slower depending on the hardware. A value of
auto(the default) enables this automatically when required for correct anti-aliasing when downscaling, and for high-quality Lanczos scaling. Set this to 0 to use the legacy fixed 4-tap Lanczos kernel. Resizing during YUV to RGB or RGB to YUV conversion always uses the generic filters. - param
-
Algorithm-specific parameter. For bicubic, this affects the filter curve. For lanczos, this sets the filter radius from 1 to 10 (default 3) when using the generic filter path; it has no effect with use_filters=0.
- force_original_aspect_ratio, force_divisible_by
-
Work the same as the identical scale filter options.
- reset_sar
-
Works the same as the identical scale filter option.
- out_range
-
Set the output YCbCr sample range. One of
auto(the default),jpeg/full/pc, ormpeg/limited/tv. - out_color_matrix
-
Set the output YCbCr matrix. One of
auto(the default),bt601,smpte170m,bt470,bt470bg,bt709,fcc,smpte240m,ycgco,bt2020orbt2020nc.With
auto, out_range and out_color_matrix are left to filter-graph negotiation. They follow a single range and matrix negotiated for the input, as for decoded video, and otherwise prefer BT.601 limited range. For RGB to YUV conversion,autothus means BT.601 limited range, unless the filter graph requires otherwise; converting full range YUV to RGB and back keeps the full range.Outside RGB to YUV conversion, these options describe the existing samples without remapping them; an unspecified input description may adopt the negotiated output description, while conflicting specified descriptions are rejected. Both options can only be used with YUV output; RGB output is full range.
Examples
-
Scale input to 720p, keeping aspect ratio and ensuring the output is yuv420p.
scale_cuda=-2:720:format=yuv420p
-
Upscale to 4K using nearest neighbour algorithm.
scale_cuda=4096:2160:interp_algo=nearest
-
Don’t do any conversion or scaling, but copy all input frames into newly allocated ones. This can be useful to deal with a filter and encode chain that otherwise exhausts the decoders frame pool.
scale_cuda=passthrough=0
-
Convert BT.709 input to RGB for a filter that requires it, then back to BT.709 NV12 with limited range.
scale_cuda=format=bgra,scale_cuda=format=nv12:out_color_matrix=bt709:out_range=limited
-
Scale to 720p while converting to RGB.
scale_cuda=-2:720:format=bgra