-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbg_formatter.sh
executable file
·175 lines (131 loc) · 3.72 KB
/
dbg_formatter.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
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
#!/bin/bash
set -u
#set -x
#----[globals]------------------------------------------------------------------------
DIRNAME=$(readlink -e $(dirname $0))
MODNAME=$(basename $0)
TERMINATED=0
#----[sources]---------------------------------------------------------------
source $DIRNAME/common_bash_functions.sh
#----[options]---------------------------------------------------------------
OPT_PROGRESS=0
OPT_DEBUG_FILEPATH=""
#----[temp files and termination]--------------------------------------------
function fnxOnEnd
{
((TERMINATED)) && { return; }
rm $TMP1 $TMP2
TERMINATED=1
}
TMP1=`mktemp`
TMP2=`mktemp`
trap 'fnxOnEnd;' 0 1 2 3 6 9 11
#----[helper functions]------------------------------------------------------
function usage
{
cat <<EOD
NAME
$MODNAME - analyses the debug output of the ssttg.sh script
SYNOPSIS
$MODNAME [-p] [-h] [debug_filepath]
DESCRIPTION
$MODNAME analyses the debug output of the ssttg.sh script.
if debug_filepath is not provided, stdin is used.
OPTIONS
-p
display progress on stderr. In this case stdout must be redirected
to some file/pipe.
This is optional.
-h
Displays this help and quits.
This is optional.
EOD
}
#----------------------------------------------------------------------------
# MAIN
#----------------------------------------------------------------------------
TEMP=`getopt -o "ph" -n "$0" -- "$@"`
eval set -- "$TEMP"
while true
do
case "$1" in
-p) OPT_PROGRESS=1; shift 1;;
-h) usage; exit 0;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [[ $# -gt 0 ]]
then
OPT_DEBUG_FILEPATH="$1"
if [[ ! -f $OPT_DEBUG_FILEPATH ]]
then
error_message "$OPT_DEBUG_FILEPATH not present"
exit 1
fi
fi
#-----------------------------------------------------------
cat $OPT_DEBUG_FILEPATH |\
gawk \
-v v_opt_progress=$OPT_PROGRESS \
'
{
++line_count
if (v_opt_progress)
printf "%08d\r", line_count > "/dev/stderr"
}
/^audio_depacketizer:info/ \
{
#audio_depacketizer:info: pkt-details, time=1611137123, pkt#=00000001, sig=c0ffeeee, ts=0000000000000000, sz=00001024
#field <ts>
print "I " extract_field_value($6)+0
next
}
/com.amagi.stt.PCMGenerator, Received-data/ \
{
#INFO, com.amagi.stt.PCMGenerator, Received-data, pts=32, len=1024
#field <pts>
print "G " extract_field_value($4)
next
}
/com.amagi.stt.PCMStreamState, get_data_from_pts/ \
{
#INFO, com.amagi.stt.PCMStreamState, get_data_from_pts, pts=-240000, hpts=0, tpts=0, status=True
#field <pts>
print "B " extract_field_value($4)
next
}
/com.amagi.stt.PCMStreamState, Resending/ \
{
#INFO, com.amagi.stt.PCMStreamState, Resending, data_ms=64.0
#field <data_ms>
print "R " extract_field_value($4)
next
}
/com.amagi.stt.SRTWriter, transcript=/ \
{
#INFO, com.amagi.stt.SRTWriter, transcript=in a;; stability=0.8999999761581421;; end_sec=34;; end_nanos=690.0;; time=1611137591.2510517;; is_final=False
log_line = $0
sub(/^.*SRTWriter, /, "", log_line)
print "T " log_line
next
}
/com.amagi.stt.SRTWriter, srt_out/ \
{
#INFO, com.amagi.stt.SRTWriter, srt_out, text=1 0000000:00:34,000 --> 0000000:00:34,800 in a
log_line = $0
sub(/^.*srt_out, text=/, "", log_line)
print "S " log_line
next
}
END \
{
if (v_opt_progress)
printf "\n" > "/dev/stderr"
}
function extract_field_value(from, _t_arr)
{
split(from, _t_arr, /[=,]/)
return _t_arr[2]
}
'