-
Notifications
You must be signed in to change notification settings - Fork 1
/
timelapse
executable file
·115 lines (102 loc) · 2.85 KB
/
timelapse
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
### Depends: imagemagick and ffmpeg
WHT="\e[1;37m"
FIN="\e[0m"
FRAMES="10"
gray_scale(){
echo -e "${WHT}Converting jpg to gray scale.${FIN}"
mogrify -colorspace gray *.jpg
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Creating time lapse video.${FIN}"
ffmpeg -r $FRAMES -f image2 -pattern_type glob -i '*.jpg' -s 1280x720 -vcodec libx264 timelapse_gray.mp4
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Results:${FIN}"
ls *.mp4
}
color_scale(){
echo -e "${WHT}Creating time lapse video.${FIN}"
ffmpeg -r $FRAMES -f image2 -pattern_type glob -i '*.jpg' -s 1280x720 -vcodec libx264 timelapse_color.mp4
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Results:${FIN}"
ls *.mp4
}
gray_scale_convert(){
echo -e "${WHT}Converting jpg to png.${FIN}"
mogrify -format png *.jpg
rm -f *.jpg
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Converting png to gray scale.${FIN}"
mogrify -colorspace gray *.png
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Creating time lapse video.${FIN}"
ffmpeg -r $FRAMES -f image2 -pattern_type glob -i '*.png' -s 1280x720 -vcodec libx264 timelapse_gray.mp4
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Results:${FIN}"
ls *.mp4
}
color_scale_convert(){
echo -e "${WHT}Converting jpg to png.${FIN}"
mogrify -format png *.jpg
rm -f *.jpg
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Creating time lapse video.${FIN}"
ffmpeg -r $FRAMES -f image2 -pattern_type glob -i '*.png' -s 1280x720 -vcodec libx264 timelapse_color.mp4
echo -e "${WHT}Done.${FIN}"
echo
echo -e "${WHT}Results:${FIN}"
ls *.mp4
}
# Commands
if [ $# -eq 0 ]; then
echo -e "\e[0;31mMissing options!${FIN}"
echo "(run $0 -h for help)"
echo ""
exit 0
fi
ECHO="false"
while getopts "cgCGh" OPTION; do
case $OPTION in
c)
ECHO="color"
;;
g)
ECHO="gray"
;;
C)
ECHO="color_convert"
;;
G)
ECHO="gray_convert"
;;
h)
echo -e "${WHT}Create a time lapse video${FIN}"
echo "Usage: Place script inside image directory"
echo ""
echo -e " -c Color Scale Video"
echo -e " -g Gray Scale Video"
echo -e " -C Color Scale Video (JPG to PNG)"
echo -e " -G Gray Scale Video (JPG to PNG)"
echo ""
exit 0
;;
esac
done
if [ $ECHO = "color" ]; then
color_scale;
fi
if [ $ECHO = "gray" ]; then
gray_scale;
fi
if [ $ECHO = "color_convert" ]; then
color_scale_convert;
fi
if [ $ECHO = "gray_convert" ]; then
gray_scale_convert;
fi