Permalink
Browse files

add two bash scripts for rotating video using exiftool with ffmpeg, t…

…hank you 🙏 @mduk
  • Loading branch information...
ipatch committed Dec 15, 2018
1 parent cd8d0ce commit 0f280d50ea0a67aca5faade144cec446497f9987
Showing with 47 additions and 0 deletions.
  1. +42 −0 jobs/bin/rotate-video
  2. +5 −0 jobs/bin/video-rotation
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

if [[ $# -lt 2 ]]
then
echo "Usage: rotate-video <file> <rotation-in-degrees>"
exit 1
fi

declare file="$1"
declare rotation="$2"

declare newfile="${file%.*}.rotated.${file##*.}"

if [[ -f "$newfile" ]]
then
echo "rotate-video: File $newfile already exists. Nothing to do."
exit 0
fi

case "$rotation" in
0)
echo "rotate-video: Video has no rotation. Nothing to do."
exit 0
;;
90) declare vf='transpose=clock' ;;
-90) declare vf='transpose=cclock' ;;
180) declare vf='transpose=clock,transpose=clock' ;;
*)
echo "rotate-video: Unknown rotation value: $rotation" >&2
exit 2
;;
esac

if [[ -z "$vf" ]]
then
echo "rotate-video: No video filter!" >&2
exit 3
fi

ffmpeg -i "file:$file" \
-vf "$vf" \
"file:$newfile"
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

declare file="$1"

exiftool "$file" | sed -n '/^Rotation/s/^.*: \(.*\)$/\1/p'

0 comments on commit 0f280d5

Please sign in to comment.