dotfiles/.local/bin/vidstab

23 lines
507 B
Bash
Executable File

#!/bin/bash
# Stabilizes a video
input=${1:?}
path="$(realpath "$input")"
file="$(basename "$path")"
dir="$(dirname "$path")"
ext="${file#*.}"
out="$dir/${file/.$ext/-stabilized.$ext}"
trf="$dir/$file.trf"
echo "path: $path"
echo "file: $file"
echo "dir : $dir"
echo "ext : $ext"
echo "out : $out"
echo "trf : $trf"
ffmpeg -i "$path" -vf vidstabdetect=result="$trf" -f null - || exit 1
ffmpeg -i "$path" -vf vidstabtransform=smoothing=5:input="$trf" "$out" || exit 2
echo "Finished processing '$file'."