Skip to content

Instantly share code, notes, and snippets.

@luismrsilva
Created June 30, 2017 05:28
Show Gist options
  • Save luismrsilva/987d272777f806deb25b815006c03b52 to your computer and use it in GitHub Desktop.
Save luismrsilva/987d272777f806deb25b815006c03b52 to your computer and use it in GitHub Desktop.
Wrapper to fix video rotation on ffmpegthumbnailer
#!/bin/bash
# WARNING: this file is provided AS IS without ANY WARRANTY.
# USE AT YOUR OWN RISK
# Installation on Ubuntu
# - Copy ffwraper.sh to /usr/share/thumbnailers
# - In ffmpegthumbnailer.thumbnailer, set:
# Exec=/usr/share/thumbnailers/ffwraper.sh -i %i -o %o -s %s
while getopts ":i:o:s:" opt; do
case $opt in
i)
i="$OPTARG";;
o)
o="$OPTARG";;
s)
s="$OPTARG";;
\?)
echo "Invalid option: -$OPTARG" >&2 ;;
esac
done
# Exec=ffmpegthumbnailer -i %i -o %o -s %s -f; convert %o -rotate $(exiftool -s -s -s %i -Rotation) %o
if [ -z "$1" ] || [ -z "$o" ] || [ -z "$s" ]; then
echo "Missing arguments." >&2
exit 1
fi
ffmpegthumbnailer -i "$i" -o "$o" -s "$s" -f
ROT=$(exiftool -s -s -s "$i" -Rotation)
if [ ! -z "$ROT" ]; then
convert "$o" -rotate "$ROT" "$o"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment