-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvidrotate
executable file
·39 lines (35 loc) · 1002 Bytes
/
vidrotate
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
31
32
33
34
35
36
37
38
39
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/vidrotate
#
if [ -z "$1" ]
then
echo "usage: $0 [file] [flip]"
echo " 0 = 90CounterCLockwise and Vertical Flip"
echo " 1 = 90Clockwise"
echo " 2 = 90CounterClockwise (default)"
echo " 3 = 90Clockwise and Vertical Flip"
echo " 4 = Flip vertically"
echo " 5 = Flip horizontally"
echo " 6 = Flip horiz then vert"
else
FLIP=${2:-2} # Default to 90-degrees CCW (left)
FLIP=${FLIP//[^0-6]/}
if [ ${FLIP} -lt 4 ]
then
TOPT="transpose=${FLIP}"
elif [ ${FLIP} -eq 4 ]
then
TOPT="vflip"
elif [ ${FLIP} -eq 5 ]
then
TOPT="hflip"
else
TOPT="hflip,vflip"
fi
TIMEBASE="-r 65535/2733" # work around timebase errors
QUALITY="-crf 17" # "-q:v 10"
ffmpeg -noautorotate -i "${1}" -acodec copy -c:v libx264 ${QUALITY} -vf "${TOPT}" "rot-${1}"
fi