Adjust FFmpeg Lenscorrection Center and Focal Coordinates

This article provides a quick guide on how to configure the optical center point and correction parameters in FFmpeg’s lenscorrection filter. You will learn how to use the coordinate parameters (cx and cy) to define the distortion center, and how the correction coefficients (k1 and k2) adjust the focal correction to eliminate barrel and pincushion lens distortion.

The lenscorrection filter in FFmpeg uses a mathematical model to correct radial lens distortion. To adjust the optical center (the point from which the radial correction propagates) and the distortion coefficients, you must configure the four primary parameters of the filter: cx, cy, k1, and k2.

The Correction Syntax

The basic syntax for applying the filter in your FFmpeg command is:

ffmpeg -i input.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=0.0:k2=0.0" output.mp4

Adjusting the Center Point (cx and cy)

The parameters cx and cy define the horizontal and vertical coordinates of the optical center (focal center) of the image.

Adjusting Focal Correction (k1 and k2)

The k1 and k2 parameters are the correction coefficients that determine the strength and direction of the correction relative to the center coordinates.

Practical Examples

Standard Center-Aligned Correction: To correct moderate barrel distortion from a centered camera lens:

ffmpeg -i input.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.1:k2=-0.05" output.mp4

Off-Center Focal Correction: If the lens axis is slightly misaligned to the top-left of the physical sensor, adjust the optical center accordingly:

ffmpeg -i input.mp4 -vf "lenscorrection=cx=0.45:cy=0.42:k1=-0.15:k2=-0.08" output.mp4