>FFmpegLab
FFmpeg Guide

Lens Correction & Distortion – Remove or Add Effects

Remove barrel distortion, fisheye, and pincushion from action cameras and wide-angle lenses. Or add creative distortion effects for music videos, dream sequences, and retro vibes.

Lens distortion is the silent enemy of action camera footage. GoPro videos have that distinctive fisheye curve. Drone footage bends at the edges. Wide-angle lenses stretch and warp straight lines into gentle arcs.

But here's the twist: sometimes you want that distortion. Music videos, dream sequences, and retro aesthetics often use lens distortion as a creative effect.

FFmpeg's lenscorrection filter can do both—remove and add lens distortion. Yet the documentation is sparse, the formula is confusing, and most users give up before finding the right parameters.

This guide changes that. You'll learn how to correct distortion for professional results and how to add creative distortion effects—all with the same powerful filter.

Key takeaways

The Gap: A Powerful Filter, Almost No Guidance

The FFmpeg documentation for lenscorrection is famously problematic. As one user noted on the FFmpeg mailing list: "I found a bug in the documentation of the lenscorrection filter... It's written there '0.5 means no correction' for the coefficients k1 and k2. This can't be right".

Indeed, testing shows that k1=0 and k2=0 produce no correction—not 0.5. The documentation has been wrong for years.

Search online, and you'll find fragmented advice. Some users recommend k1=-0.227:k2=-0.022 for GoPro. Others suggest k1=-0.18:k2=0.006 for newer models. But almost no one explains how these values are calculated or why they work. And almost no one explains how to use the filter creatively.

This guide bridges that gap with clear explanations, working examples for both removal and addition, and a practical approach to finding your camera's correction parameters.

The Symptom: "Why Are My GoPro Videos So Curved?"

You've shot amazing footage with your action camera. But when you watch it back, straight lines are curved, the horizon bends, and the edges of the frame are stretched. The footage looks unmistakably fisheye.

Or maybe you're making a music video and you want that trippy, distorted look. You want to add barrel distortion to your footage for a dreamlike effect.

Whether you're removing or adding distortion, the lenscorrection filter is the tool. Let's explore both directions.

Core Concepts: Barrel, Pincushion & Fisheye

Lens distortion comes in three main flavors:

The lenscorrection filter uses a radial distortion model based on the distance from the center of the image.

The distortion formula is:

r_img = r_src * (1 + k1 * (r_src / r_0)^2 + k2 * (r_src / r_0)^4)

Where:

Understanding the signs:

It's a classic "same filter, opposite direction" situation. The lenscorrection filter applies the inverse of the distortion formula. So specifying k1 and k2 tells FFmpeg what distortion exists, and it calculates the inverse to correct it.

The lenscorrection Filter Parameters

Here's every parameter you need to know, with practical guidance for each.

ParameterDefaultWhat it doesWhen to adjust
cx 0.5 Relative x-coordinate of the distortion center (0=left, 1=right) Usually leave at 0.5. Adjust if your lens's optical center is off-center
cy 0.5 Relative y-coordinate of the distortion center (0=top, 1=bottom) Usually leave at 0.5. Adjust if your lens's optical center is off-center
k1 0 Coefficient of the quadratic correction term Removal: negative for barrel, positive for pincushion
Add: positive for barrel, negative for pincushion
k2 0 Coefficient of the quartic correction term Usually smaller than k1. Helps fine-tune the effect at the edges

Critical note: k1=0 and k2=0 mean no correction. The documentation's claim that "0.5 means no correction" is incorrect.

Remove: GoPro Fisheye Removal

Let's correct the classic GoPro fisheye distortion. GoPro cameras use extreme wide-angle lenses that create significant barrel distortion.

ShareRenders { } Code Config
Generated Code Logs Customize
# Remove GoPro fisheye (Hero 3/4 style)
ffmpeg -i gopro_input.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.227:k2=-0.022" -c:a copy output_corrected.mp4

What's happening here?

These values are widely used for GoPro Hero 3 and 4 cameras.

ShareRenders { } Code Config
Generated Code Logs Customize
# GoPro Hero 5/6 correction (slightly different values)
ffmpeg -i gopro_hero5.mp4 -vf "lenscorrection=k1=-0.18:k2=0.006" -c:a copy output_corrected.mp4

Note: k2 is positive here—different lenses require different correction profiles. As one user noted: "There is no universal setting(s) to cover all GoPro models and lenses".

Remove: Barrel Distortion Correction

Not all barrel distortion comes from GoPros. Many action cameras, drones, and wide-angle lenses exhibit similar effects.

ShareRenders { } Code Config
Generated Code Logs Customize
# General barrel distortion correction (tune k1 and k2 for your lens)
ffmpeg -i wideangle_input.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.15:k2=-0.01" -c:a copy output_corrected.mp4

Start with k1=-0.1 and k2=0, then adjust both until straight lines appear straight. The k2 parameter fine-tunes the correction at the edges of the frame.

Remove: Pincushion Distortion

Pincushion distortion is less common but appears in telephoto lenses and some zoom lenses. The correction uses positive values.

ShareRenders { } Code Config
Generated Code Logs Customize
# Pincushion distortion correction (positive k1/k2)
ffmpeg -i telephoto_input.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=0.1:k2=0.01" -c:a copy output_corrected.mp4

Positive k1 and k2 values correct pincushion distortion by pulling the corners outward.

Add: Creative Lens Distortion Effects

Now for the creative side—adding lens distortion for artistic effect. Music videos, dream sequences, retro aesthetics, and psychedelic visuals often use lens distortion as a creative tool.

Adding Barrel Distortion (Fisheye Effect)

To add barrel distortion to normal footage (creating a fisheye-like effect), use positive k1 and k2 values.

ShareRenders { } Code Config
Generated Code Logs Customize
# ADD barrel distortion (fisheye effect) – positive values
ffmpeg -i normal_video.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=0.15:k2=0.01" -c:a copy output_fisheye.mp4

This creates a subtle fisheye effect. Increase k1 for a more dramatic effect.

Adding Pincushion Distortion

To add pincushion distortion (lines bow inward), use negative values.

ShareRenders { } Code Config
Generated Code Logs Customize
# ADD pincushion distortion – negative values
ffmpeg -i normal_video.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.12:k2=-0.008" -c:a copy output_pincushion.mp4

This creates a subtle pincushion effect, making the image appear to pinch inward at the corners.

Extreme Fisheye (Action Camera Style)

For an extreme fisheye effect like a GoPro, use larger positive values.

ShareRenders { } Code Config
Generated Code Logs Customize
# Extreme fisheye effect (GoPro style)
ffmpeg -i normal_video.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=0.3:k2=0.04" -c:a copy output_fisheye_strong.mp4

Warning: Extreme values will create significant black corners (since the image is stretched outward). You'll need to crop the edges or accept the artistic effect.

Animated Distortion Effect

For a dynamic, animated distortion (perfect for music videos), you can use sendcmd or zmq to change the distortion coefficients over time. Or, for a simpler approach, use timeline expressions to switch between different distortion levels.

ShareRenders { } Code Config
Generated Code Logs Customize
# Animated distortion using setpts and dynamic parameters (requires sendcmd)
# Create a command file: distortion_commands.txt
# 0.0   lenscorrection k1 0.15
# 1.0   lenscorrection k1 0.3
# 2.0   lenscorrection k1 0.15

ffmpeg -i normal_video.mp4 -filter_complex "sendcmd=f=distortion_commands.txt,asplit[lens]" -c:a copy output_animated.mp4

This creates a pulsing distortion effect that waxes and wanes over time—perfect for a music video or dream sequence.

Combining with Other Effects

Lens distortion pairs beautifully with other effects. Here's a "vintage lens" combination with vignette and color grading:

ShareRenders { } Code Config
Generated Code Logs Customize
# Vintage lens effect: distortion + vignette + color grading
ffmpeg -i normal_video.mp4 \
-vf "lenscorrection=k1=0.08:k2=0.005, vignette=0.3, colorlevels=rimax=0.85:gimax=0.8:bimax=0.9" \
-c:a copy output_vintage.mp4

Calculating k1 and k2 – The Hard Part

Finding the right k1 and k2 values for your specific camera is the biggest challenge. Here are three approaches.

Approach 1: Known Values for Popular Cameras

For popular cameras, you can find known values online:

As one user noted: "There is no universal setting(s) to cover all GoPro models and lenses". Different models and even different firmware versions can change the distortion profile.

Approach 2: Calibration with a Grid or Chessboard

For precise calibration, photograph a known pattern (like a chessboard) and adjust k1 and k2 until the lines are straight. This is the approach used by OpenCV's camera calibration.

However, there's a catch: the k1 and k2 parameters in FFmpeg's lenscorrection are different from the parameters calculated by OpenCV. As one developer noted: "The k1,k2 parameters in vf_lenscorrection.c should be converted".

Approach 3: Trial and Error (The Practical Approach)

For most users, trial and error is the most practical approach:

  1. Start with k1=-0.1, k2=0 for barrel correction
  2. Encode a short test clip and check the results
  3. If the edges are still curved, increase k1 (more negative)
  4. If the center is over-corrected, add k2 (negative or positive)
  5. Repeat until straight lines are straight

For creative effects, the process is the same—but you're aiming for a specific look, not mathematical perfection.

Performance & Quality Considerations

Lens correction is computationally intensive. Here are some considerations.

Quality Issues: Moiré Patterns

One known issue with the lenscorrection filter is that it can create moiré patterns or bad interpolation artifacts, especially with high-frequency content like fine patterns or text.

To minimize these artifacts:

Edge Cropping

When correcting barrel distortion, the edges of the frame are pulled inward, revealing empty (black) pixels at the corners. When adding distortion, the opposite happens—the image is stretched outward, and you lose content at the edges.

To handle this:

For creative effects, black corners can actually enhance the aesthetic—it's part of the "lens look."

Performance

Lens correction is a pixel-by-pixel operation. For 4K video, it can be slow. Consider using a lower resolution for testing, and only apply the final correction at full resolution.

Debugging Common Issues

Here are the most common issues and how to fix them.

ProblemLikely CauseFix
No effect applied k1=0 and k2=0 Set k1 and/or k2 to non-zero values
Effect is reversed (wrong distortion direction) k1 or k2 has the wrong sign Removal: barrel=negative, pincushion=positive
Add: barrel=positive, pincushion=negative
Moiré patterns High-frequency content with interpolation artifacts Scale down before correction; use gentler correction values
Black corners (removal) Correction pulls edges inward Crop the edges or scale the image up slightly
Lost content at edges (addition) Distortion stretches the image outward Add padding before distortion, or scale down after
Center is over-corrected k1 is too strong Reduce k1 and adjust k2 to compensate

Visualize with the FFmpegLab IDE

Lens correction is much easier to tune with visual feedback. The FFmpegLab IDE lets you:

Here's how lens correction tuning looks in the FFmpegLab IDE—with both removal and addition modes.

ShareRenders { } Code Config
Generated Code Logs Customize
# Creative lens distortion: adding fisheye effect
ffmpeg -i normal_video.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=0.15:k2=0.01" -c:a copy output_fisheye.mp4

The IDE shows you exactly what's happening—the original image, the distorted result, and a grid overlay that makes it easy to see the effect. You can toggle between "Remove" and "Add" modes, adjust k1 and k2 with sliders, and see the result in real time.

Frequently Asked Questions (FAQ)

How do I remove barrel distortion with lenscorrection?

Use negative values for k1 and k2. For example, GoPro Hero 3/4: k1=-0.227:k2=-0.022. The filter applies the inverse distortion to straighten the image.

How do I add barrel distortion for a creative effect?

Use positive values for k1 and k2. Start with k1=0.1:k2=0.01 and increase for a stronger effect. This creates a fisheye-like look.

Why does the documentation say "0.5 means no correction"?

The documentation is incorrect. Testing confirms that k1=0:k2=0 produces no correction. The "0.5" reference appears to be a documentation bug.

Can I animate the distortion effect over time?

Yes. Use sendcmd or zmq to change k1 and k2 dynamically. This allows you to create pulsing, growing, or decaying distortion effects—perfect for music videos and dream sequences.

Does lenscorrection work on fisheye images?

Yes. The lenscorrection filter can correct fisheye distortion, but it may not produce perfect results for extreme fisheye (180°+ FOV). For those cases, consider using the v360 filter to convert to equirectangular projection first.

Can I use lenscorrection with other filters?

Absolutely. You can chain lenscorrection with any other video filter. Common combinations include vignette, color grading, and scaling. For creative effects, try combining distortion with vignette and colorlevels for a vintage lens look.

Final Word

Lens correction is one of FFmpeg's most underrated features. The lenscorrection filter can transform curved, distorted footage into professional-looking video—and just as easily add creative distortion effects for artistic projects.

The key is understanding the relationship between k1, k2, and distortion direction:

Finding the right values takes some trial and error, but with the FFmpegLab IDE's visual feedback and real‑time preview, you can tune your correction (or creative effect) in minutes instead of hours.

Next time you're frustrated by curved horizons—or inspired to create a trippy music video—reach for lenscorrection. It works both ways.

✦  Fresh from the render queue

Better FFmpeg workflows, delivered.

Get practical commands, new templates, and deep-dive guides for the edits that are usually hardest to get right.

✓  Copy-pasteable commands    ✓  Editor templates    ✓  No noise
One useful email at a time.