Created
July 23, 2012 03:10
-
-
Save dedman/3161847 to your computer and use it in GitHub Desktop.
Convert all HD mov files in iPhoto directory to SD so can sync to iPad
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
### BACKUP IPHOTO LIBRARY FIRST BEFORE RUNNING ANYTHING | |
#Place this file in ~/Pictures/iPhoto Library and run. | |
#brew install ffmpeg if you don't have ffmpeg installed | |
rm -rf converted | |
for x in $(find . -iname \*.mov) ; do | |
ffmpeg -i $x 2>&1 | grep -q '1920x1080' | |
if [ $? == 1 ] | |
then | |
continue | |
fi | |
a=$(ffmpeg -i $x 2>&1 | grep 'rotate') | |
echo $a | |
transpose="" | |
if [[ $a == *90* ]] | |
then | |
transpose="-vf transpose=1" | |
fi | |
if [[ $a == *180* ]] | |
then | |
transpose="-vf vflip,hflip" | |
fi | |
if [[ $a == *270* ]] | |
then | |
transpose="-vf transpose=3" | |
fi | |
dir=$(dirname converted/$x) | |
mkdir -p $dir | |
ffmpeg -i $x -s 1280x720 $transpose converted/$x | |
#Adjust date to original file date | |
d=$(stat -t %Y%m%d%H%M.%S $x | cut -d\ -f12) | |
echo touch -t ${d//\"/\ } converted/$x | |
touch -t ${d//\"/\ } converted/$x | |
dir=$(dirname hd_backups/$x) | |
mkdir -p $dir | |
mv $x hd_backups/$x | |
mv converted/$x $x | |
echo "NEXT" | |
done | |
echo "DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment