video.sh 1.12 KB
Newer Older
Cassio Kirch's avatar
.sh    
Cassio Kirch committed
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
#!/bin/bash

mv one_system*dat old/
rm *.dat

make optimize || exit 1
./boids4 || exit $?

rm pictures/[0-9]*.png &> /dev/null || echo "nada removido"

moviename=$(ls one_system*dat).avi

gpParameters="notitle w p ps 3 pt 7"

range=$(grep "\#define RANGE " define.h | awk '{print $3*0.5}')

steps=$(( $(grep "\#define STEPS " define.h | awk '{print $3}') / $(grep "\#define EXIT_INTERVAL " define.h | awk '{print $3}') ))

echo -e "\nsteps: $steps"
for (( i=0; i<$steps ; i++ ))
do
    array[$i]=$i
    #grep -P "^${array[$i]}\t" one_system*dat > ${array[$i]}.dat
    ((echo -e "set terminal png size 1200,1200;
               set xrange[-$range:$range];
               set yrange[-$range:$range];
               set output 'pictures/${array[$i]}.png';
               plot './${array[$i]}_0.dat' u 3:4 $gpParameters lc rgb 'red',\
 './${array[$i]}_1.dat' u 3:4 $gpParameters lc rgb 'blue' ") | gnuplot)
    if [ $((i%100)) == 0 ]; then
	echo -ne "${array[$i]} " &
    fi
done



echo -e "\n\n"
cd pictures

FFMpegParameters="-r 10 -i %d.png -vcodec libx264"
avconv $FFMpegParameters ../$moviename ||
    ffmpeg $FFMpegParameters ../$moviename