Skip to content

Instantly share code, notes, and snippets.

@TaylorJadin
Last active March 16, 2023 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TaylorJadin/9cfbb21e2943ab3e3bfd946a94e64b3d to your computer and use it in GitHub Desktop.
Save TaylorJadin/9cfbb21e2943ab3e3bfd946a94e64b3d to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Uses ffmpeg to stabilize video. Give the script one or more files and it will do its thing.
#
# Needs an ffmpeg binary compiled with support for vidstab, you can find that at the site if this script doesn't work:
# https://www.johnvansickle.com/ffmpeg/
#
# More info / based on:
# https://www.imakewebsites.ca/posts/2018/02/17/stabilizing-gopro-video-with-ffmpeg-and-vid.stab/
# https://rainnic.altervista.org/en/how-stabilize-video-using-ffmpeg-and-vidstab?language_content_entity=en
for filename in "$@"; do
ffmpeg -y -i $filename -vf vidstabdetect=stepsize=32:shakiness=10:accuracy=10:result=transform_vectors.trf -f null -
ffmpeg -y -i $filename -vf vidstabtransform=input=transform_vectors.trf:zoom=0:smoothing=10,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -tune film -acodec copy -preset slow ${filename%.*}_stabilized.mp4
rm transform_vectors.trf
done
rm transform_vectors.trf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment