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

    Positional shorthand:

    ffmpeg -i input.mp4 -vf "xbr=2" -c:a copy output_2x.mp4
  • 3x Upscaling (Default):

    ffmpeg -i input.mp4 -vf "xbr=n=3" -c:a copy output_3x.mp4
  • 4x Upscaling:

    ffmpeg -i input.mp4 -vf "xbr=n=4" -c:a copy output_4x.mp4

Key Considerations

  • Supported Factors: The xbr filter only natively supports fixed factors of 2, 3, and 4. Arbitrary values (such as 5 or fractional multipliers like 2.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 xbr filters together or combine xbr with a standard scale filter using the nearest-neighbor flag:

    ffmpeg -i input.mp4 -vf "xbr=n=4,xbr=n=2" -c:a copy output_8x.mp4
  • Color Space Handling: The xbr filter operates on RGB pixel formats. If your input video uses a standard YUV format (like yuv420p), 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 yuv420p when encoding.