aboutsummaryrefslogtreecommitdiff
path: root/tools/rotate-video.sh
blob: 5ce4efe57790612c35980681cfc8a1239ec4b13a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

set -e

DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE[0]}")" )" &>/dev/null && pwd )"
PROGNAME="$0"

. "$DIR/../include/bash/include.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"