-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgifit
executable file
·36 lines (31 loc) · 1.16 KB
/
gifit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# USAGE: gifit [MOVIE]
#
# This program will convert the .mov MOVIE file into a gif with the same name,
# copy it over to ~/Dropbox/Public/gifs and copy the Dropbox public URL for the
# gif to your clipboard.The gif conversion commands are extracted from
# https://gist.github.com/SlexAxton/4989674.
#
# The Dropbox copy requires the 'DROPBOX_USER_ID' variable to be set.
output() {
echo $*
osxnotify $*
}
if [[ ! -f "$1" ]]; then
echo "Usage: $(basename $0) MOVIE.mov [--share]"
exit 1
fi
movie="$1"
path=$(basename $movie)
filename=${path%.*}
gif="$filename.gif"
ffmpeg -i $movie -r 10 -vcodec png out-static-%05d.png 2> /dev/null
convert -verbose +dither -layers Optimize -resize 900x900\> out-static*.png gif:- 2> /dev/null | gifsicle --colors 128 --delay=1 --loop --optimize=3 --multifile - > $gif
rm out-static*.png
output "🎥 '$gif' created."
if $(command -v dropbox_uploader.sh &>/dev/null) && [ $2 == "--share" ]; then
dropbox_uploader.sh upload "$gif" "Public/gifs/$gif"
dropbox_uploader.sh share "Public/gifs/$gif" | sed -e 's/> Share link: //' | pbcopy
output "👉 Shareable Dropbox URL for '$gif' copied to your clipboard."
rm "$gif"
fi