Created
September 8, 2018 22:40
-
-
Save kowalcj0/bd88621e4be9951fbc6de8d2cb564fae to your computer and use it in GitHub Desktop.
Stabilise shaky video with ffmpeg and vid.stab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias stabilize=stabilize | |
function stabilize() { | |
type ffmpeg >/dev/null 2>&1 || { echo >&2 "ffmpeg is required but it's not installed."; return 1; } | |
video="${1}" | |
filename="${1%.*}" | |
extension="${1##*.}" | |
output="${filename}-stabilized.${extension}" | |
# calculate transformation vectors | |
ffmpeg -nostdin -hide_banner -i "${video}" -vf vidstabdetect=stepsize=6:shakiness=8:accuracy=15:result=transform_vectors.trf -f null - | |
# stabilise video using transformation vectors from previous step | |
ffmpeg -nostdin -hide_banner -i "${video}" -vf vidstabtransform=input=transform_vectors.trf:zoom=1:smoothing=30,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -preset slow -tune film -crf 18 -acodec copy "${output}" | |
rm -fr transform_vectors.trf | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment