-
Notifications
You must be signed in to change notification settings - Fork 3
/
stat2html
executable file
·163 lines (153 loc) · 5.37 KB
/
stat2html
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
#! /bin/sh
# helper-script for noad
# convert noad-statistic-file to html
# changes:
# add some more cols
# automatic detetction of statisticlines from previous versions
# sort the lines by recording-name and noad scan-date
# add some calculations
if test $# -lt 2
then
echo "usage:"
echo "stat2html <statfile> <htmlfile> [videodir]"
exit -1
fi
# write html-header
echo "<html>" > $2
echo "<head>" >>$2
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\">" >>$2
echo "</head>" >>$2
echo "<body>" >> $2
# write table header
echo "<table border="1">" >> $2
echo "<tr>" >> $2
echo "<th valign=\"top\">Scan-Datum</th>" >> $2
echo "<th valign=\"top\">Version</th>" >> $2
echo "<th valign=\"top\">Blacklines<br>ac3<br>overlap</th>" >> $2
echo "<th valign=\"top\">Auflösung</th>" >> $2
echo "<th valign=\"top\">Gesamtframes<br/>(Laufzeit)</th>" >> $2
echo "<th valign=\"top\">decodierte<br/>Frames</th>" >> $2
echo "<th valign=\"top\">decodierte<br/>Frames<br/>für<br/>Logo- erkennung</th>" >> $2
echo "<th valign=\"top\">Zeit<br/>für<br/>Logo- erkennung<br/>(Sek.)</th>" >> $2
echo "<th valign=\"top\">decodierte<br/>Frames<br/>für<br/>Logo- prüfung</th>" >> $2
echo "<th valign=\"top\">Zeit<br/>für<br/>Logo- prüfung<br/>(Sek.)</th>" >> $2
echo "<th valign=\"top\">Gesamtzeit<br/>für<br/>Scan</th>" >> $2
echo "<th valign=\"top\">Name der Aufzeichnung</th>" >> $2
echo "<th valign=\"top\">Kommentar</th>" >> $2
echo "</tr>" >> $2
# cmd for kick out a given vidoeo-dirname
if [ $# -gt 2 ]
then
stripvdir="sed -e s*$3** -e s*//**g -e s*\;/*\;*"
else
stripvdir="cat"
fi
# convert statfile from noad-0.3.2/0.3.2a
gawk -F';' '{ if(NF > 10) printf("%s\n",$0); \
else {\
for(i=1;i<=NF;i++) {\
if(i==2){\
printf("0.3.2;-;-;");\
}\
if(i!=NF)\
printf("%s;",$i);\
else\
printf("%s",$i);\
}\
printf("\n");\
}\
};' $1 |
# convert statfile from intermediate version
gawk -F';' '{ if(NF > 12) printf("%s\n",$0); \
else {\
for(i=1;i<=NF;i++) {\
if(i==2){\
printf("0.3.2;");\
}\
if(i!=NF)\
printf("%s;",$i);\
else\
printf("%s",$i);\
}\
printf("\n");\
}\
};' |
# convert total-scantime from secs to time and add a reminder for markpic in col 12
gawk -F';' '{ \
for(i=1;i<11;i++) \
{printf("%s;",$i); } \
h=$11/3600; \
m=$11/60%60; \
s=$11%60; \
printf("%d:%02d:%02d;",h,m,s); \
for(j=12;j<=NF;j++) \
{ printf("%s;",$j); } \
printf("\n"); \
}' |
# sort input by recordingname and scan-date
sed -e 's/,/;/' |
sort -k 13,13 -k 2,2 -t';' |
sed -e 's/;/,/' |
# strip the video-dir out of the recording-name
$stripvdir |
# set alignments and change some special characters
sed -e 's/^/<tr><td>/' \
-e 's/\//<br\/>/g'\
-e 's/,/<br\/>/'\
-e 's/ /<br\/>/'\
-e '/0.4.2/s/,/<br\/>/'\
-e '/0.4.2/s/,/<br\/>/'\
-e 's/;/<\/td><td align="right">/1'\
-e 's/;/<\/td><td align="right">/1'\
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td align="right">/1' \
-e 's/;/<\/td><td valign=\"top\">/g'\
-e 's/(/<br\/>(/'\
-e 's/add your comment here//'\
-e 's/_/ /g' \
-e 's/#2E/./g' \
-e 's/#27/'\''/g' \
-e 's/#3A/:/g' \
-e 's/#3F/?/g' \
-e 's/$/<\/td><\/tr>/' |
# colorize rows for better reading
gawk '{ if(NR%2==1) gsub("<tr>","<tr bgcolor=\"#f0f0f0\">"); printf("%s\n",$0); }' >> $2
# add some statistics
gawk -F';' '{ if(NF > 10) { \
totalframes += $5; scantime += $11; decFrames += $6 \
} \
else { \
totalframes += $2; scantime += $8; decFrames += $3 \
} \
}; \
END {\
stotal = totalframes/25; \
mtotal = stotal / 60 % 60;\
htotal = stotal / 3600;\
stotal %= 60; \
mscan = scantime / 60 % 60;\
hscan = scantime / 3600;\
sscan = scantime%60;\
printf("<tr><td></td><td></td><td></td><td></td>"\
"<td align=\"right\" valign=\"top\">%d<br/>(%d:%02d:%02d)</td>"\
"<td align=\"right\" valign=\"top\">%d<br/>%d%%<br/>%dfps</td>"\
"<td></td>"\
"<td></td>"\
"<td></td>"\
"<td></td>"\
"<td align=\"right\" valign=\"top\">%d:%02d:%02d<br/>%d%%</td>"\
"<td></td>"\
"<td></td>", \
totalframes,int(htotal),int(mtotal),int(stotal),\
decFrames,decFrames*100/totalframes,decFrames/scantime,\
hscan,mscan,sscan,scantime*100/(totalframes/25)) }' $1 >> $2
# write table-end
echo "</table>" >> $2
echo "</body>" >> $2
echo "</html>" >> $2