-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcreate-avi.sh
executable file
·51 lines (42 loc) · 1.01 KB
/
create-avi.sh
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
#!/bin/bash
# Should be called with the path to the jpgs to be converted as first argument
# resolution of the jpgs as the second argument, optional fps as third
if [ $# -le 1 ]; then
echo "usage: $0 path_to_jpgs resolution_of_jpgs [fps]"
exit 1
fi
path_jpgs=$1
resolution_jpgs=$2
fps_jpgs=10
if [ $# -eq 3 ]; then
fps_jpgs=$3
fi
_dir="jpgs"
_unique_name_count=1
while [ -d $_dir ]; do
_dir=$_dir$_unique_name_count
_unique_name_count=$((_unique_name_count+1))
done
mkdir $_dir
# making a directory containing the jpgs in directory 'path_jpgs' and naming them X.jpeg where X is an ascending number starting from 1.
count=1
for file in $(ls $path_jpgs | sort -n); do
e=${file%*.jpeg}
f=${file%*.jpg}
if [ ! $e = $file ] || [ ! $f = $file ]; then
cp $path_jpgs/$file $_dir/$count.jpeg
count=$((count+1))
fi
done
# calling the program!
if cd bin; then
./avimake -r $resolution_jpgs -l ../$_dir -n $((count-1)) -s $fps_jpgs
mv Video.avi ../Video.avi
cd ..
fi
# cleanup
if cd $_dir; then
rm *
cd ..
rmdir $_dir
fi