Fix fisheye distortion for GoPro videos

1 min read

Sometimes you may need to remove fisheye effect from your videos. Correcting distortion will give almost the same results as shooting with a wide-angle non-fisheye lens.

Use ffmpeg with a built-in filter lenscorrection.

ffmpeg -i <input_file> -map_metadata 0 -c:a copy -c:v h264 -crf 22 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.227:k2=-0.022" <output_file>

Keys are:

Params k1 and k2 for lenscorrection filter are individual for each camera and can be calculated from H fov, W fov and Diag fov. See a stackoverflow answer for more info.

To fix all *.mp4 files in the directory:

for filename in ./*.mp4; do [ -e "$filename" ] || continue ffmpeg -i $filename -map_metadata 0 -c:a copy -c:v h264 -crf 22 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.227:k2=-0.022" $filename-fixed.mp4 done