-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDOCSV_template.pl
executable file
·255 lines (235 loc) · 5.03 KB
/
DOCSV_template.pl
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/usr/bin/perl
use Cwd;
use Env;
use Term::ANSIColor qw(:constants);
use Image::Magick;
#http://www.imagemagick.org/script/command-line-options.php
$script = $0;
print BOLD BLUE "script : $script\n";print RESET;
@tmp=split(/\//,$script);
$scriptname=$tmp[$#tmp];
$CWD=getcwd;
#get project name
@tmp=split(/\//,$CWD);
$PROJECT=$tmp[$#tmp];
print BOLD BLUE "project : $PROJECT\n";print RESET;
#defaults
$FSTART=1;
$FEND=100;
$SHOT="";
$INDIR="$CWD/originales";
$IN="ima";
$OUTDIR="$CWD/artistic";
$ZEROPAD=1;
$FORCE=0;
$EXT="png";
$VERBOSE=0;
$FORCE=0;
#gpu id
$GPU=0;
$CSV=0;
sub verbose {
if ($VERBOSE) {print BOLD GREEN "@_\n";print RESET}
}
sub isnum ($) {
#returns 0 if string 1 if number
#http://www.perlmonks.org/?node=How%20to%20check%20if%20a%20scalar%20value%20is%20numeric%20or%20string%3F
return 0 if $_[0] eq '';
$_[0] ^ $_[0] ? 0 : 1
}
sub confstr {
#format lines for autoconf
($str) = @_;
if (isnum(${$str}))
{$line="\$$str=${$str}\;\n";}
else
{$line="\$$str=\"${$str}\"\;\n";}
return $line;
}
sub autoconf {
open (AUTOCONF,">","csv.conf");
print AUTOCONF confstr(PROJECT);
print AUTOCONF confstr(FSTART);
print AUTOCONF confstr(FEND);
print AUTOCONF confstr(SHOT);
print AUTOCONF confstr(INDIR);
print AUTOCONF confstr(IN);
print AUTOCONF confstr(OUTDIR);
print AUTOCONF confstr(EXT);
print AUTOCONF "1\n";
}
#arguments
if ($#ARGV == -1) {
print "usage: $scriptname \n";
print "-help\n";
print "-autoconf\n";
print "-conf file.conf\n";
print "-f startframe endframe\n";
print "-force [0]\n";
print "-verbose\n";
print "-gpu gpu_id [0]\n";
print "-csv csv_file.csv\n";
exit;
}
for ($arg=0;$arg <= $#ARGV;$arg++)
{
if (@ARGV[$arg] eq "-autoconf")
{
print "writing csv_auto.conf --> mv csv_auto.conf csv.conf\n";
autoconf();
if (-e "$OUTDIR") {print "$OUTDIR already exists\n";}
else {$cmd="mkdir $OUTDIR";system $cmd;}
if (-e "$STYLEDIR") {print "$STYLEDIR already exists\n";}
else {$cmd="mkdir $STYLEDIR";system $cmd;}
exit;
}
if (@ARGV[$arg] eq "-conf")
{
$CONF=@ARGV[$arg+1];
print BOLD BLUE "configuration file : $CONF\n";print RESET;
require $CONF;
if (-e "$OUTDIR") {print "$OUTDIR already exists\n";}
else {$cmd="mkdir $OUTDIR";system $cmd;}
}
if (@ARGV[$arg] eq "-f")
{
$FSTART=@ARGV[$arg+1];
$FEND=@ARGV[$arg+2];
print BOLD BLUE "seq : $FSTART $FEND\n";print RESET;
}
if (@ARGV[$arg] eq "-zeropad4")
{
$ZEROPAD=1;
print "zeropad4 ...\n";
}
if (@ARGV[$arg] eq "-force")
{
$FORCE=1;
print "force output ...\n";
}
if (@ARGV[$arg] eq "-gpu")
{
$GPU=@ARGV[$arg+1];
$LOG1=" > /var/tmp/artistic_$GPU.log";
$LOG2=" 2> /var/tmp/artistic_$GPU.log";
print "gpu id : $GPU\n";
}
if (@ARGV[$arg] eq "-verbose")
{
$VERBOSE=1;
$LOG1="";
$LOG2="";
print "verbose ...\n";
}
if (@ARGV[$arg] eq "-size")
{
$SIZE=@ARGV[$arg+1];
print "size : $RESIZE\n";
}
if (@ARGV[$arg] eq "-csv")
{
$CSVFILE=@ARGV[$arg+1];
print "csv file : $CSVFILE\n";
$CSV=1;
}
}
$userName = $ENV{'USER'};
if (($userName eq "dev") || ($userName eq "render")) #
{
$GMIC="/usr/bin/gmic";
}
sub csv {
#style
$SSTYLE=$STYLE;
$SSTYLE=~ s/.jpg//;
$SSTYLE=~ s/.jpeg//;
$SSTYLE=~ s/.png//;
$SSTYLE=~ s/\.//;
$IIN="$INDIR/$SHOT/$IN\_$SSTYLE.\%04d.png";
$OUT="$OUTDIR/$SHOT.mov";
if (-e "$OUTDIR")
{print "$OUTDIR already exists\n";}
else
{$cmd="mkdir $OUTDIR";system $cmd;}
#$touchcmd="touch $OOUTDIR/$OUT";
#system $touchcmd;
$cmd="ffmpeg -start_number $FSTART -i $IIN -c:v prores -profile:v 3 $OUT";
verbose $cmd;
system $cmd;
}#csv sub
#main
if ($CSV)
{
open (CSV , "$CSVFILE");
while ($line=<CSV>)
{
chop $line;
@line=split(/,/,$line);
$SHOT=@line[0];
$STYLE=@line[1];
$STYLESCALE=@line[2];
$FSTART=@line[3];
$FEND=@line[4];
$LENGTH=@line[5];
$process=@line[6];
$suffix=@line[7];
if ($process)
{
csv();
}
}
}
else
{
csv();
}
#-------------------------------------------------------#
#---------gestion des timecodes ------------------------#
#-------------------------------------------------------#
sub hmstoglob {
my ($s,$m,$h) = @_;
my $glob;
#
$glob=$s+60*$m+3600*$h;
return $glob;
}
sub globtohms {
my ($glob) = @_;
my $floath=$glob/3600;
my $h=int($floath);
#
my $reste=$glob-3600*$h;
my $floatm=$reste/60;
my $m=int($floatm);
#
my $s=$glob-3600*$h-60*$m;
#
return ($s,$m,$h);
}
sub timeplus {
#($s,$m,$h)=timeplus($s1,$m1,$h1,$s2,$m2,$h2)
my ($s1,$m1,$h1,$s2,$m2,$h2) = @_;
$glob1=hmstoglob($s1,$m1,$h1);
$glob2=hmstoglob($s2,$m2,$h2);
$glob=$glob1+$glob2;
($s,$m,$h) =globtohms($glob);
return ($s,$m,$h);
}
sub lapse {
#($s,$m,$h)=lapse($s1,$m1,$h1,$s2,$m2,$h2)
my ($s1,$m1,$h1,$s2,$m2,$h2) = @_;
$glob1=hmstoglob($s1,$m1,$h1);
$glob2=hmstoglob($s2,$m2,$h2);
if ($glob1 > $glob2)
{
$glob1=86400-$glob1;
$glob=$glob2+$glob1;
}
else
{
$glob=$glob2-$glob1;
}
# print "$glob1 $glob2 $glob \n";
my ($s,$m,$h) =globtohms($glob);
return ($s,$m,$h);
}