Set Upscaling Factor in FFmpeg xBR Filter
This guide explains how to select the upscaling factor (2x, 3x, or
4x) when using the xbr video filter in FFmpeg. The xBR
algorithm is specifically designed for scaling pixel art and retro video
game graphics, and FFmpeg allows you to set the target scale multiplier
directly through a dedicated filter parameter.
In FFmpeg, the upscaling factor for the xbr filter is
controlled using the n option. The filter accepts integer
values of 2, 3, or 4,
representing 2x, 3x, and 4x magnification, respectively. If no factor is
specified, FFmpeg defaults to 3 (3x scaling).
Syntax and Parameters
You can specify the factor by explicitly naming the option
(n=X) or by providing the value as a positional
argument.
2x Upscaling:
ffmpeg -i input.mp4 -vf "xbr=n=2" -c:a copy output_2x.mp4Positional shorthand:
ffmpeg -i input.mp4 -vf "xbr=2" -c:a copy output_2x.mp43x Upscaling (Default):
ffmpeg -i input.mp4 -vf "xbr=n=3" -c:a copy output_3x.mp44x Upscaling:
ffmpeg -i input.mp4 -vf "xbr=n=4" -c:a copy output_4x.mp4
Key Considerations
Supported Factors: The
xbrfilter only natively supports fixed factors of2,3, and4. Arbitrary values (such as5or fractional multipliers like2.5) are not supported and will cause FFmpeg to return an error.Higher Multipliers: If you need scaling beyond 4x (such as 8x or 16x), you can chain multiple
xbrfilters together or combinexbrwith a standardscalefilter using the nearest-neighbor flag:ffmpeg -i input.mp4 -vf "xbr=n=4,xbr=n=2" -c:a copy output_8x.mp4Color Space Handling: The
xbrfilter operates on RGB pixel formats. If your input video uses a standard YUV format (likeyuv420p), FFmpeg will automatically convert it to RGB to apply the filter, and then re-encode it. To maintain compatibility with web players, ensure you convert the output format back using-pix_fmt yuv420pwhen encoding.