Skip to content

Commit

Permalink
Add video rotation fixing script
Browse files Browse the repository at this point in the history
  • Loading branch information
AgenttiX committed Nov 11, 2024
1 parent e579532 commit 10ec6c5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions zsh/custom/video.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ trim_video() {
fi
ffmpeg -i $1 -ss $2 -to $3 -c:v copy -c:a copy $4
}

fix_rotation() {
# Fix wrong rotation metadata in a video.
# Custom Android ROMs can sometimes give wrong orientation sensor data,
# resulting in wrong orientation metadata in video recordings.
if [ $# -lt 1 ]; then
echo "Usage: fix_rotation <source paths>"
fi
for ARG in "$@"; do
NAME="${ARG%.*}"
SUFFIX="${ARG##*.}"
OLD_NAME="${NAME}-old.${SUFFIX}"
mv "${ARG}" "${OLD_NAME}"
ffmpeg -display_rotation 0 -i "${OLD_NAME}" -c copy "${ARG}"
done
}

0 comments on commit 10ec6c5

Please sign in to comment.