Skip to content

Instantly share code, notes, and snippets.

@dedman
Created July 23, 2012 03:10
Show Gist options
  • Save dedman/3161847 to your computer and use it in GitHub Desktop.
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
### 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