Last active
April 21, 2021 10:53
-
-
Save kardysm/ba824852bdff0cbd11febcc0e66dbeeb to your computer and use it in GitHub Desktop.
Rotate mp4 video 90* (by default) clockwise via ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TMP_PATH="/tmp/rotating-vids" | |
# Provide path to source directory | |
ARG_DIRECTORY="${1:-.}" | |
# Transposition settings, default 90 deg clockwise | |
TRANSPOSE="${2:-1}" | |
DIR=$(dirname $ARG_DIRECTORY) | |
VIDEOS=$(find $DIR -type f -name "*.MP4" -print0 | xargs -r0) | |
mkdir -p $TMP_PATH | |
echo "directory: $DIR" | |
echo "transcoding: " | |
for video in $VIDEOS; do | |
ffmpeg -i $video -vf "transpose=$TRANSPOSE" "$TMP_PATH/rotated-$(basename $video)" | |
echo "file $(basename $i) transcoded ($TMP_PATH/rotated-$(basename $video))" | |
done | |
mv $TMP_PATH/* $DIR | |
rm -r $TMP_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment