Skip to content

Instantly share code, notes, and snippets.

@caio2k
Last active September 7, 2021 19:15
Show Gist options
  • Save caio2k/a7ccf36e03edce1e0b14b878dc989458 to your computer and use it in GitHub Desktop.
Save caio2k/a7ccf36e03edce1e0b14b878dc989458 to your computer and use it in GitHub Desktop.
stabilize and normalize video
#!/bin/bash
function video_edit(){
rm -f transforms.trf
ffmpeg -i "${1}" -vf vidstabdetect=shakiness=5 -f null -
case "$1" in
*.MTS) VCODEC="-vcodec libx264" ;;
*) VCODEC= ;;
esac
if [ -f transforms.trf ]; then
#ffmpeg -i "${1}" -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -tune film -acodec copy -preset slow "stab-${1}"
ffmpeg -y -i "${1}" -vf vidstabtransform=interpol=bicubic,unsharp=5:5:0.8:3:3:0.4 $VCODEC -acodec copy "stab-${1}"
rm transforms.trf
ffmpeg-normalize -f "stab-${i}" -o "norm-stab-${i}.mkv"
else
ffmpeg-normalize -f "${i}" -o "norm-${i}.mkv"
fi
}
if [ $# -eq 0 ]; then
echo "No files to transform given"
exit 1
fi
if ! command -v ffmpeg-normalize &> /dev/null; then
pip3 install ffmpeg-normalize
fi
for i in "$@"; do
video_edit "${i}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment