Create a gist now

Instantly share code, notes, and snippets.

@troutcolor /pum.sh
Last active Nov 19, 2017

What would you like to do?
#script to download pile of flickr images and make a movie like the pummelvision service # example https://vimeo.com/196182638 #needs ffmpeg #needs sips so a mac I think
#!/bin/bash
# set -ex bail if something fails and print lines as they are executed
set -ex
#script to download pile of flickr images and make a movie like the pummelvision service
# example https://vimeo.com/196182638
#needs ffmpeg
#needs sips so a mac I think
#Fill in the param any except the APIKEY can be empty
APIKEY='YOURAPIKEYHERE'
USERID='71428177%40N00'
SINCEDATE='2015-01-01'
#unix timestamp or mysql datetime
TAGS='water'
NUMPHOTOS='10'
PHOTOSORT='date-posted-desc'
#date-posted-desc
#date-posted-asc
#date-posted-desc
#date-taken-asc
#date-taken-desc
#interestingness-desc
#interestingness-asc
#relevance
FRAMESPERSECOND=2
searchurl="https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=${APIKEY}&user_id=${USERID}&media=photos&min_taken_date=${SINCEDATE}&text=${TAGS}&extras=url_o&sort=${PHOTOSORT}&per_page=${NUMPHOTOS}&format=rest"
#Make a temp directory to work in
TEMPDIR=$(mktemp -d -t 'mytmpdir')
HERE=$( pwd )
trap "{ cd $HERE ; rm -rf $TEMPDIR; exit 255; }" SIGINT
cd $TEMPDIR
FILELIST=$(curl "$searchurl" | sed -ne 's/.*\(http[^"]*\).*/\1/p')
a=`echo $FILELIST | wc -w`
let a=a+1
new=$(printf "%04d.jpg" "$a")
curl -o $new https://farm9.staticflickr.com/8718/16191965623_9dacf5c640_o_d.jpg > $new
for i in $FILELIST ; do
let a=a-1
new=$(printf "%04d.jpg" "$a")
curl -o $new $i
done;
sips --resampleHeight 768 *.jpg
sips --padToHeightWidth 786 1024 *.jpg
ffmpeg -framerate ${FRAMESPERSECOND} -i %04d.jpg -c:v libx264 flickr.mp4
PS3='Please enter your choice: '
options=("Rolling at 5" "Lagoa v2" "Off to Osaka" "Hyper Fun" "Scattershot")
select opt in "${options[@]}"
do
case $opt in
"Rolling at 5")
echo "downloading."
curl http://incompetech.com/music/royalty-free/mp3-royaltyfree/Rollin%20at%205.mp3 > background.mp3
break
;;
"Lagoa v2")
echo "downloading Lagoa v2"
curl http://incompetech.com/music/royalty-free/mp3-royaltyfree/Lagoa%20v2.mp3 > background.mp3
break
;;
"Off to Osaka")
echo "downloading Off to Osaka"
curl http://incompetech.com/music/royalty-free/mp3-royaltyfree/Off%20to%20Osaka.mp3 > background.mp3
break
;;
"Hyper Fun")
echo "downloading Hyper Fun"
curl http://incompetech.com/music/royalty-free/mp3-royaltyfree/Hyperfun.mp3 > background.mp3
break
;;
"Scattershot")
echo "downloading Scattershot"
curl http://incompetech.com/music/royalty-free/mp3-royaltyfree/Scattershot.mp3 > background.mp3
break
;;
*) echo invalid option;;
esac
done
ffmpeg -i flickr.mp4 -i background.mp3 -map 0 -map 1 -codec copy -codec:a aac -strict experimental -b:a 192k -shortest flickr-audio.mp4
#mv "$TEMPDIR/r5outyuv420p.mp4" $HERE
mv "$TEMPDIR/flickr-audio.mp4" $HERE
cd $HERE
rm -rf $TEMPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment