FFmpeg Unsharp Filter: Box and Gaussian Sharpening
This guide explains how to use the FFmpeg unsharp filter
to enhance video clarity using box or Gaussian sharpening techniques.
You will learn the exact syntax of the filter, the role of each
parameter (such as matrix size and sharpening amount), and see practical
command-line examples for applying sharpening to both the luma
(brightness) and chroma (color) channels of your videos.
Understanding the Unsharp Filter Syntax
The unsharp filter in FFmpeg works by applying a blur to
the video (using a fast box-blur approximation of a Gaussian blur) and
subtracting it from the original image to detect edges and increase
contrast.
The basic syntax for the filter is:
unsharp=luma_msx:luma_msy:luma_amount:chroma_msx:chroma_msy:chroma_amountYou can also use named parameters for better readability:
unsharp=l_msx=5:l_msy=5:l_amount=1.0:c_msx=0:c_msy=0:c_amount=0Parameter Breakdown
luma_msx/luma_msy(Luma Matrix Size X/Y): Sets the horizontal and vertical kernel size for the luma channel. It must be an odd integer between3and63(e.g., 3, 5, 7, 9, etc.). Larger matrix sizes create a wider blur/sharpening radius, simulating larger Gaussian curves.luma_amount(Luma Sharpening Amount): Determines the strength of the sharpening.- A positive float value (typically
0.0to1.5) sharpens the image. - A negative float value (typically
-2.0to0.0) blurs the image. 0.0disables the effect.
- A positive float value (typically
chroma_msx/chroma_msy(Chroma Matrix Size X/Y): Sets the kernel size for the chroma (color) channels. Must be an odd integer.chroma_amount(Chroma Sharpening Amount): Determines the sharpening strength for the color channels. It is usually recommended to keep this at0.0or low values to avoid adding color noise and artifacts.
Practical Examples
1. Default Gaussian-Like Sharpening (Luma Only)
For most standard video sharpening tasks, you only want to sharpen
the luma channel to avoid color distortion. The following command uses a
5x5 matrix with a moderate strength of
1.0:
ffmpeg -i input.mp4 -vf "unsharp=5:5:1.0:0:0:0" -c:a copy output.mp42. Subtle Sharpening for High-Resolution Video (1080p / 4K)
When dealing with high-resolution footage, a larger matrix size is
required to make the sharpening visible. This command uses a
7x7 matrix with a subtle strength of 0.6:
ffmpeg -i input.mp4 -vf "unsharp=l_msx=7:l_msy=7:l_amount=0.6" -c:a copy output.mp43. Strong Box/Gaussian Sharpening
If your video is noticeably blurry, you can increase the matrix size and sharpening amount. Use this with caution, as high values can introduce “halos” around high-contrast edges:
ffmpeg -i input.mp4 -vf "unsharp=l_msx=9:l_msy=9:l_amount=1.5" -c:a copy output.mp44. Sharpening Both Luma and Chroma
If you want to sharpen both the details and the color boundaries of the video, you can apply a smaller matrix size and lower amount to the chroma channels:
ffmpeg -i input.mp4 -vf "unsharp=5:5:0.8:3:3:0.4" -c:a copy output.mp4Tips for Best Results
- Keep Chroma at Zero: In most cases, leave the last
three parameters (
chroma_msx,chroma_msy,chroma_amount) at0to prevent color fringing. - Avoid Over-Sharpening: Do not set the
amounthigher than1.5unless absolutely necessary, as it introduces digital noise and compression artifacts. - Match the Resolution: Use smaller matrix sizes
(e.g.,
3x3or5x5) for low-resolution videos (480p) and larger matrix sizes (e.g.,7x7to11x11) for HD or 4K videos.