Sharpen Horizontal Video Details with FFmpeg Unsharp

This article explains how to use the FFmpeg unsharp filter to target and sharpen only the horizontal details of a video while leaving vertical details untouched. You will learn the exact filter parameters required, how they function, and how to execute the command-line syntax to achieve this specific visual effect.

The unsharp filter in FFmpeg uses a matrix-based approach to apply sharpening or blurring to the luma (brightness) and chroma (color) channels of a video. To restrict the sharpening effect solely to the horizontal axis, you must configure the horizontal matrix size while setting the vertical matrix size to its minimum, non-effective value.

The Unsharp Filter Syntax

The basic syntax for the unsharp filter is defined as follows:

unsharp=luma_msize_x:luma_msize_y:luma_amount:chroma_msize_x:chroma_msize_y:chroma_amount

To sharpen only horizontal details, configure the parameters using these rules:

  • luma_msize_x (lx): Set this to an odd integer between 5 and 23 (e.g., 7 or 9). This defines the horizontal search span for edge detection.
  • luma_msize_y (ly): Set this to 3. This is the minimum matrix size, which effectively disables vertical filtering.
  • luma_amount (la): Set this to a positive decimal (typically between 0.5 and 2.0) to define the intensity of the horizontal sharpening.
  • Chroma parameters (cx, cy, ca): To avoid color artifacts and noise, it is best to disable chroma sharpening by setting the chroma amount (ca) to 0 and both matrix dimensions to 3.

Command Example

Below is the standard FFmpeg command to sharpen only the horizontal luma details of a video:

ffmpeg -i input.mp4 -vf "unsharp=7:3:1.5:3:3:0" -c:a copy output.mp4

Parameter Breakdown

  • 7: Sets the horizontal luma matrix size to 7 pixels wide, allowing the filter to detect and sharpen horizontal transitions.
  • 3: Sets the vertical luma matrix size to 3 (neutral), preventing vertical sharpening.
  • 1.5: Applies a strong, highly visible sharpening effect to the horizontal luma edges.
  • 3:3:0: Disables both horizontal and vertical chroma sharpening by setting the chroma matrix sizes to 3 and the chroma sharpening amount to 0.