How to Sharpen Horizontal Video Details in FFmpeg

This guide explains how to use FFmpeg's native unsharp video filter to sharpen only the horizontal details of a video stream. By configuring the filter's horizontal and vertical matrix dimensions independently, you can enhance horizontal sharpness, accentuate vertical lines, and prevent unwanted vertical sharpening artifacts without altering color planes.

Understanding the Unsharp Filter Parameters

The unsharp filter in FFmpeg uses an unsharp masking algorithm that blurs an edge mask and subtracts it from the original image to increase local contrast. The filter accepts parameters for luma (brightness) and chroma (color) components using the following syntax:

unsharp=lx:ly:la:cx:cy:ca

  • lx (luma_msize_x): Horizontal matrix size for luma. Must be an odd integer between 3 and 63. Default is 5.
  • ly (luma_msize_y): Vertical matrix size for luma. Must be an odd integer between 3 and 63. Default is 5.
  • la (luma_amount): Strength of the luma effect. Values range from -1.5 (maximum blur) to 1.5 (maximum sharpening). Default is 1.0.
  • cx, cy, ca: The corresponding horizontal size, vertical size, and amount for the chroma channels.

Configuring for Horizontal Sharpening

Because FFmpeg requires matrix sizes to be odd integers with a minimum value of 3, an unsharp mask cannot be completely set to zero on the vertical axis. To isolate the sharpening effect to horizontal details as much as possible, set the vertical matrix dimension (ly) to its lowest possible value (3) and expand the horizontal matrix dimension (lx) to a larger odd value (such as 7, 9, or 13).

A wider horizontal kernel samples and sharpens horizontal contrast transitions while minimizing vertical edge enhancement. Setting the chroma amount (ca) to 0 also prevents color noise and fringing.

FFmpeg Command Examples

Basic Horizontal Sharpening

To apply a moderate horizontal sharpen to a video while keeping chroma untouched:

ffmpeg -i input.mp4 -vf "unsharp=lx=9:ly=3:la=1.0:cx=3:cy=3:ca=0" -c:a copy output.mp4

Using the shorthand parameter syntax:

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

Strong Horizontal Sharpening

For footage that is soft horizontally (such as anamorphic footage or content scaled unevenly), increase the horizontal matrix radius and boost the effect strength:

ffmpeg -i input.mp4 -vf "unsharp=lx=13:ly=3:la=1.4:cx=3:cy=3:ca=0" -c:a copy output.mp4

Subtle Enhancement

If the maximum sharpness creates halo artifacts along high-contrast vertical edges, reduce la to a lower positive value between 0.3 and 0.6:

ffmpeg -i input.mp4 -vf "unsharp=lx=7:ly=3:la=0.5:cx=3:cy=3:ca=0" -c:a copy output.mp4

Parameter Recommendations

  • Horizontal Size (lx): Use 7 for mild enhancement, 9 to 11 for standard sharpening, and 13 or higher for low-resolution or heavily blurred sources.
  • Vertical Size (ly): Always keep this at 3 to limit vertical edge enhancement.
  • Amount (la): Keep between 0.4 and 1.0 for natural-looking results. Exceeding 1.2 often introduces noticeable halos along edges.