summaryrefslogtreecommitdiff
path: root/tools/rotate-video.sh
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-06-16 15:59:40 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-06-16 22:36:40 +0300
commit46af1e90f5867e3f141ceb230a3b71a05c310840 (patch)
treed188e0e880a83b4c789a43ef412f35bdd8fb72fc /tools/rotate-video.sh
parentbd3c5487b526c441b76304b15e13b0ef3b26105f (diff)
video utils updated
Diffstat (limited to 'tools/rotate-video.sh')
-rwxr-xr-xtools/rotate-video.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/rotate-video.sh b/tools/rotate-video.sh
new file mode 100755
index 0000000..6d27b44
--- /dev/null
+++ b/tools/rotate-video.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+
+DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE[0]}")" )" &>/dev/null && pwd )"
+PROGNAME="$0"
+
+. "$DIR/lib.bash"
+
+
+usage() {
+ cat <<EOF
+usage: $PROGNAME FILENAME
+EOF
+ exit 1
+}
+
+[[ $# -lt 1 ]] && usage
+
+oldname="$1"
+if file_in_use "$oldname"; then
+ die "file $oldname is in use by another process"
+fi
+
+newname="${oldname/.mp4/_rotated.mp4}"
+
+ffmpeg -y -i "$(realpath "$1")" -map_metadata 0 -metadata:s:v rotate="90" -codec copy \
+ "$(realpath "$newname")"
+rm "$oldname"
+mv "$newname" "$oldname" \ No newline at end of file