Skip to content

Commit 10ec6c5

Browse files
committed
Add video rotation fixing script
1 parent e579532 commit 10ec6c5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

zsh/custom/video.zsh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ trim_video() {
77
fi
88
ffmpeg -i $1 -ss $2 -to $3 -c:v copy -c:a copy $4
99
}
10+
11+
fix_rotation() {
12+
# Fix wrong rotation metadata in a video.
13+
# Custom Android ROMs can sometimes give wrong orientation sensor data,
14+
# resulting in wrong orientation metadata in video recordings.
15+
if [ $# -lt 1 ]; then
16+
echo "Usage: fix_rotation <source paths>"
17+
fi
18+
for ARG in "$@"; do
19+
NAME="${ARG%.*}"
20+
SUFFIX="${ARG##*.}"
21+
OLD_NAME="${NAME}-old.${SUFFIX}"
22+
mv "${ARG}" "${OLD_NAME}"
23+
ffmpeg -display_rotation 0 -i "${OLD_NAME}" -c copy "${ARG}"
24+
done
25+
}

0 commit comments

Comments
 (0)