How to Adjust Unsharp Filter Radius in FFmpeg
Adjusting the horizontal and vertical search radii in FFmpeg’s
unsharp filter allows you to control the span of the
sharpening or blurring effect. This guide explains how to configure the
luma and chroma matrix sizes—which define these search radii—using
specific command-line parameters to achieve precise control over your
video’s sharpness.
The unsharp filter in FFmpeg uses a coordinate grid
(matrix) to determine the area of neighboring pixels to analyze. This
matrix size represents the horizontal and vertical search radii. You can
adjust these values independently for both the luma (brightness) and
chroma (color) channels.
The Radius Parameters
The horizontal and vertical search radii are controlled by the following parameters:
luma_msize_x(orlx): Luma horizontal matrix size (horizontal radius).luma_msize_y(orly): Luma vertical matrix size (vertical radius).chroma_msize_x(orcx): Chroma horizontal matrix size.chroma_msize_y(orcy): Chroma vertical matrix size.
Parameter Rules
- Allowed Values: Must be an odd
integer between
3and23(e.g., 3, 5, 7, 9, up to 23). - Default Value: The default size for all dimensions
is
5. - Effect: A larger matrix size increases the search radius, applying the sharpening or blurring effect over a wider area. A smaller size limits the effect to immediate neighboring pixels.
Command Examples
You can define these parameters using either named options or positional shorthand.
Example 1: Adjusting Luma Radius with Named Parameters (Recommended)
To set a horizontal search radius of 7 and a vertical
search radius of 3 for the luma channel, use:
ffmpeg -i input.mp4 -vf "unsharp=luma_msize_x=7:luma_msize_y=3:luma_amount=1.5" output.mp4Example 2: Adjusting Luma and Chroma Radii with Shorthand Names
To quickly set both luma and chroma search radii to 9x9
with custom sharpness amounts:
ffmpeg -i input.mp4 -vf "unsharp=lx=9:ly=9:la=1.2:cx=9:cy=9:ca=0.5" output.mp4la(luma amount) andca(chroma amount) determine the strength of the filter. Positive values sharpen; negative values blur.
Example 3: Using Positional Parameters
If you do not want to use parameter names, you can pass the values in
order:
luma_msize_x:luma_msize_y:luma_amount:chroma_msize_x:chroma_msize_y:chroma_amount
To set a 7x7 luma radius and a 5x5 chroma
radius:
ffmpeg -i input.mp4 -vf "unsharp=7:7:1.2:5:5:0.5" output.mp4