Sharpen a Blurry Video with FFmpeg’s unsharp Filter
To sharpen the edges in a video with FFmpeg, use the unsharp filter. It works for small videos that look blurry after being enlarged, slightly out-of-focus footage, and screen recordings where you want the text to be easier to read.
In a test environment, I deliberately blurred footage containing text and stripes, changed the strength and range of unsharp, and measured how close the result came to the original. The default settings do sharpen, but they produce white and black halos around edges, and on noisy footage they also make the noise stronger.
The test environment was Ubuntu 24.04.5, FFmpeg 6.1.1 (Ubuntu package 6.1.1-3ubuntu5), and a 4-core CPU. The source material was a 1280×720, 25 fps, 4-second (100-frame) video that I drew with Python (Pillow). It contains text, thin stripes, a black square, a gray panel, and a boundary between red and blue. I blurred it in two ways: by shrinking it to half size and scaling it back up (hereafter the "upscale-blurred video"), and by blurring it with the gblur filter (sigma=2). I did not test real camera footage, other sharpening filters (such as cas or smartblur), or filters that run on the GPU.
- 1. Command You Can Use As Is
- 2. What the Three Numbers Mean
- 3. Comparing Strength and Range Results
- 4. Halos Appear Around Edges (White and Black)
- 5. Noise Gets Stronger Too, So Denoise First
- 6. When Upscaling Small Videos, Scale First, Then Sharpen
- 7. Color Edges Stay the Same Unless You Set ca
- 8. Invalid Values and Errors
Command You Can Use As Is
ffmpeg -i input.mp4 -vf unsharp=5:5:1.5 -c:v libx264 -crf 23 -c:a copy output.mp4
When I tried this on an MP4 with audio, the video stayed H.264, the audio stayed AAC, and the length stayed at 4.000000 seconds. -c:a copy tells FFmpeg to copy the audio stream without re-encoding it (Streamcopy section of the FFmpeg documentation).
The 1.5 in 5:5:1.5 is the strength. In the measurements below, raising the default 1.0 to 1.5 brought the upscale-blurred video closer to the original. However, the best value depends on how blurry the footage is and how much noise it has. Cut out a short section and decide while watching it.
What the Three Numbers Mean
According to the unsharp documentation, the three numbers in unsharp=5:5:1.5 mean the following, in order:
luma_msize_x(lx): the horizontal size of the area used to process brightness. An odd number from 3 to 23. The default is 5.luma_msize_y(ly): the vertical size, with the same rules. The default is 5.luma_amount(la): the strength of the brightness effect. The default is 1.0. Positive values sharpen, negative values blur, and 0 does nothing.
After these come the same three values for color (chroma_*) and transparency (alpha_*). If you write nothing else, it is the same as 5:5:1.0:5:5:0.0. By default, the color effect strength is 0.
In the source code for FFmpeg 6.1.1, each pixel is computed as "original value + (original value − blurred neighborhood value) × strength." Because the filter emphasizes the difference from the blurred neighborhood, the bright side of an edge becomes brighter and the dark side becomes darker. Widening the range (lx, ly) compares each pixel against a larger neighborhood.
Comparing Strength and Range Results
I applied unsharp to the blurred videos and compared the results with the original (unblurred) video. I used the psnr filter and the ssim filter for the comparison. In both, a higher value means closer to the original. The table shows values for brightness (Y).
| Setting | Upscale-blurred video PSNR | Upscale-blurred video SSIM | gblur video PSNR | gblur video SSIM |
|---|---|---|---|---|
| Before applying | 24.27 dB | 0.9604 | 20.63 dB | 0.9228 |
unsharp (default 5:5:1.0) |
27.62 dB | 0.9707 | 22.40 dB | 0.9462 |
unsharp=5:5:1.5 |
28.24 dB | 0.9708 | 23.43 dB | 0.9559 |
unsharp=5:5:2.5 |
27.93 dB | 0.9684 | 25.90 dB | 0.9716 |
unsharp=5:5:5 |
27.33 dB | 0.9580 | 34.54 dB | 0.9869 |
unsharp=3:3:1.0 |
26.41 dB | 0.9691 | 21.73 dB | 0.9381 |
unsharp=3:3:2.0 |
27.70 dB | 0.9713 | 22.98 dB | 0.9513 |
unsharp=7:7:1.0 |
28.24 dB | 0.9703 | 22.87 dB | 0.9512 |
unsharp=7:7:2.5 |
28.24 dB | 0.9651 | 27.51 dB | 0.9776 |
unsharp=9:9:1.0 |
28.52 dB | 0.9691 | 23.19 dB | 0.9546 |
unsharp=13:13:1.0 |
28.69 dB | 0.9673 | 23.57 dB | 0.9579 |
The best setting differed between the two videos. For the upscale-blurred video, the highest SSIM came from 3:3:2.0, and raising the strength to 2.5 or 5 lowered SSIM. For the heavily gblur-blurred video, PSNR and SSIM kept rising even when I increased the strength up to the maximum of 5. With these two videos, the more heavily blurred gblur video got closer to the original as I raised the strength.
Processing time (from reading the 4-second video until the lossless FFV1 output was finished writing; each value is a single run) was 0.84 seconds with no filter on the upscale-blurred video, and 1.07 to 1.69 seconds with unsharp applied. For the gblur video, it was 0.83 seconds with no filter and 1.25 to 1.83 seconds with unsharp. In both cases, wider ranges were slightly slower, and 13:13 took the longest.

With unsharp=5:5:1.5, the thin lines of the small text became clearer. With the upper limit 5:5:5, the text became bolder and darker than the original.
Halos Appear Around Edges (White and Black)
I lined up the brightness values (Y) along one horizontal row across the boundary between a black square and a white background. In this video, black is 16 and white is 235.

In the upscale-blurred video, the transition from black to white took about 2.1 pixels (the width from 10% to 90%). The default unsharp reduced this to about 1.6 pixels, 5:5:1.5 to about 1.2 pixels, and 5:5:2.5 to about 0.9 pixels. The original video is about 0.8 pixels.
The trade-off is that, even with the default unsharp, the values just outside the boundary reached 255 on the white side and 0 on the black side. This creates a halo that is brighter than white and darker than black. The upscale-blurred video already had small halos of 241 and 10 from the upscaling calculation, and unsharp strengthened them.
Noise Gets Stronger Too, So Denoise First
unsharp strengthens every difference from the neighborhood, including noise. I added frame-to-frame noise to the upscale-blurred video with the noise filter (alls=6:allf=t), then measured the brightness variation (standard deviation) inside the gray panel.
| Setting | Gray panel standard deviation | SSIM | File size after H.264 encoding |
|---|---|---|---|
| Before applying | 3.17 | 0.8414 | 275,397 bytes |
unsharp (default) |
5.96 | 0.6629 | 6,176,249 bytes |
unsharp=5:5:1.5 |
7.36 | 0.5792 | 8,957,103 bytes |
unsharp=5:5:2.5 |
10.19 | 0.4522 | ― |
hqdn3d=4,unsharp |
3.47 | 0.8345 | 898,353 bytes |
unsharp,hqdn3d=4 |
5.11 | 0.7217 | ― |
The default unsharp alone increased the variation by about 1.9 times, and SSIM dropped below the value before applying the filter. The file encoded as H.264 (libx264 -crf 23 -preset medium) was about 22 times larger. When I encoded the upscale-blurred video without added noise using the same settings, it was 29,580 bytes before the filter and 30,532 bytes with the default unsharp, so the size barely changed.

When I reduced noise first with the hqdn3d filter and then applied unsharp, the variation was 3.47, almost the same as before applying the filter. In the reverse order (unsharp,hqdn3d=4), it was 5.11, and the strengthened noise remained. Filters separated by commas in -vf are applied from left to right, so for noisy footage, put hqdn3d first.
ffmpeg -i input.mp4 -vf hqdn3d=4,unsharp -c:v libx264 -crf 23 -c:a copy output.mp4
When Upscaling Small Videos, Scale First, Then Sharpen
When upscaling a 640×360 video to 1280×720, I compared placing unsharp before and after the scaling step.
| Setting | PSNR | SSIM |
|---|---|---|
scale=1280:720:flags=bicubic only |
24.27 dB | 0.9604 |
unsharp,scale=1280:720:flags=bicubic |
26.58 dB | 0.9626 |
scale=1280:720:flags=bicubic,unsharp |
27.62 dB | 0.9707 |
scale=1280:720:flags=lanczos only |
24.85 dB | 0.9620 |
scale=1280:720:flags=lanczos,unsharp |
29.21 dB | 0.9682 |
Applying unsharp after scaling gave higher PSNR and SSIM. Scaling with lanczos and then applying unsharp gave the highest PSNR, but for SSIM, scaling with bicubic and then applying unsharp was higher.
Color Edges Stay the Same Unless You Set ca
By default, the color effect strength (chroma_amount) is 0, so color edges are left unchanged. I checked this at the boundary between red and blue. With unsharp, unsharp=5:5:1.5, and unsharp=la=1.5, the color information (the U and V planes) at frame 50 was identical to the unfiltered version (compared by MD5).
If you also want to sharpen color edges, specify the last three values too. With unsharp=5:5:1.0:5:5:1.0, the change in the red-related value (V) became steeper at the red-blue boundary. The values on either side of the boundary widened from 214 and 112 before applying the filter to 226 and 100. In the original video they are 211 and 115, so as with brightness, values overshoot beyond the edge.
ffmpeg -i input.mp4 -vf unsharp=5:5:1.0:5:5:1.0 -c:v libx264 -crf 23 -c:a copy output.mp4
Invalid Values and Errors
ffmpeg -h filter=unsharp shows the range size as (from 3 to 23) and the strength as (from -2 to 5). However, even within these ranges, some combinations are not valid.
Even sizes cannot be used. unsharp=4:4:1.0 stopped with the following error (I have omitted the memory addresses that begin with @ 0x…, and the same applies below):
[Parsed_unsharp_0] Invalid even size for luma matrix size 4x4
Combinations where the width and height sum is too large also cannot be used. unsharp=15:15:1.0 and unsharp=23:5:1.0 each stopped with the following errors (the first line is for 15:15, the second for 23:5):
[Parsed_unsharp_0] luma matrix size (lx/2+ly/2)*2=28 greater than maximum value 25
[Parsed_unsharp_0] luma matrix size (lx/2+ly/2)*2=26 greater than maximum value 25
Twice the sum of lx and ly, each divided by 2 (with fractions truncated), must be 25 or less (relevant source code). If you keep the width and height the same, the maximum is 13:13. You can make only one dimension large, as in 23:3.
unsharp=5:5:6, with a strength above 5, stopped with Value 6.000000 for parameter 'luma_amount' out of range [-2 - 5]. The official documentation suggests that values from -1.5 to 1.5 are practical.
If you make the strength negative, as in unsharp=5:5:-1.0, the video becomes blurrier instead of sharper. On the upscale-blurred video, PSNR dropped from 24.27 dB to 20.64 dB. A mistyped sign will produce a video that is blurrier than the original.



