Sharpen Blurry Video Using FFmpeg Unsharp Filter
This guide provides a straightforward tutorial on how to fix blurry
videos using FFmpeg’s built-in unsharp video filter. You
will learn the exact command-line syntax, understand how the filter’s
parameters work, and see practical examples to restore clarity and
detail to your video files.
The unsharp filter in FFmpeg works by applying a blur
matrix to the video and subtracting it from the original image, which
effectively enhances the edges and details.
The Unsharp Filter Syntax
The basic structure of the unsharp filter parameter
is:
unsharp=luma_msize_x:luma_msize_y:luma_amount:chroma_msize_x:chroma_msize_y:chroma_amount
These parameters are divided into two main categories: Luma (which controls the brightness and detail/edges) and Chroma (which controls the color).
- msize_x and msize_y (Matrix Size): These define the width and height of the search matrix. They must be odd integers between 3 and 23. A larger matrix size applies the effect over a wider area.
- amount (Sharpness Strength): This defines the
strength of the effect. It is a decimal number between -1.5 and 1.5.
- Positive values (0.0 to 1.5) sharpen the image.
- Negative values (-1.5 to 0.0) blur the image.
0.0leaves the image unchanged.
Practical Command Examples
To apply the filter, use the -vf (video filter) flag in
your FFmpeg command.
1. Default Sharpening
If you want to apply a moderate, safe level of sharpening without manually tweaking numbers, you can run the filter with its default settings:
ffmpeg -i input.mp4 -vf "unsharp" output.mp4The default settings are 5:5:1.0:5:5:0.0, which
sharpens the luma (details) by a factor of 1.0 while leaving the chroma
(colors) untouched.
2. Strong Sharpening for Very Blurry Videos
If your video is noticeably blurry, you can increase both the matrix size and the sharpening amount for the luma:
ffmpeg -i input.mp4 -vf "unsharp=7:7:1.5" output.mp4This uses a larger 7x7 matrix and sets the sharpening intensity to the maximum value of 1.5.
3. Sharpening Both Detail and Color
In some cases, sharpening the colors (chroma) along with the details (luma) can improve the video’s appearance. Use the following command to apply moderate sharpening to both:
ffmpeg -i input.mp4 -vf "unsharp=5:5:0.8:5:5:0.4" output.mp4This sharpens the details by 0.8 and the colors by 0.4.
Tips for Best Results
- Avoid Over-Sharpening: Setting the
amounttoo high (above 1.2) can introduce “halo” artifacts around edges and increase visual noise/grain in the video. - Combine with Hardware Acceleration: Sharpening is
CPU-intensive. If you are converting large files, consider adding your
GPU’s encoder settings (like
-c:v h264_nvencfor NVIDIA or-c:v h264_videotoolboxfor Mac) to speed up the process.