-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathscopes
executable file
·181 lines (154 loc) · 3.8 KB
/
scopes
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
#!/bin/sh
#===============================================================================
# scopes
# ffplay video scopes
#===============================================================================
# dependencies:
# ffplay
#===============================================================================
# script usage
#===============================================================================
usage()
{
[ -z "${1}" ] || echo "! ${1}"
echo "\
# ffplay video scopes
$(basename "$0") -i input = histogram
$(basename "$0") -o input = rgb overlay
$(basename "$0") -p input = rgb parade
$(basename "$0") -s input = rgb overlay and parade
$(basename "$0") -w input = waveform
$(basename "$0") -v input = vector scope
$(basename "$0") -h = help
"
exit 2
}
#===============================================================================
# error messages
#===============================================================================
INVALID_OPT_ERR='Invalid option:'
REQ_ARG_ERR='requires an argument'
WRONG_ARGS_ERR='wrong number of arguments passed to script'
#===============================================================================
# check the number of arguments passed to the script
#===============================================================================
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"
#===============================================================================
# functions
#===============================================================================
# histogram overlay
histogram_overlay () {
ffplay "${infile}" \
-hide_banner \
-stats -v panic \
-vf \
"split=2[a][b],
[b]histogram,
format=yuva444p[hh],
[a][hh]overlay=x=W-w:y=H-h"
}
# rgb overlay
rgb_overlay () {
ffplay "${infile}" \
-hide_banner \
-stats -v panic \
-vf \
"format=gbrp,
split=2[a][b],
[b]waveform=g=green:
s=ire:
fl=numbers:
filter=lowpass:
components=7:
display=overlay[bb],
[a][bb]vstack"
}
# rgb parade
rgb_parade () {
ffplay "${infile}" \
-hide_banner \
-stats -v panic \
-vf \
"format=gbrp,
split=2[a][b],
[b]waveform=g=green:
s=ire:
fl=numbers:
filter=lowpass:
components=7[bb],
[a][bb]vstack"
}
# rgb overlay and parade stacked
rgb_stacked () {
ffplay "${infile}" \
-hide_banner \
-stats -v panic \
-vf \
"format=gbrp,
split=3[a][b][c],
[b]waveform=g=green:
s=ire:
fl=numbers:
filter=lowpass:
components=7:
display=overlay[bb],
[c]waveform=g=green:
s=ire:
fl=numbers:
filter=lowpass:
components=7[cc],
[bb][cc]vstack[d],
[a][d]vstack"
}
# waveform lowpass
waveform_lowpass () {
ffplay "${infile}" \
-hide_banner \
-stats -v panic \
-vf \
"split=2[a][b],
[b]waveform=f=lowpass:
s=ire:
g=green:
e=instant[bb],
[a][bb]vstack"
}
# vectorscope
vectorscope () {
ffplay "${infile}" \
-hide_banner \
-stats -v panic \
-vf \
"format=yuva444p9,
split=2[m][v],
[v]vectorscope=b=0.7:
m=color4:
e=peak+instant:
f=name:
g=color[v],
[m][v]overlay=x=W-w:y=H-h"
}
#===============================================================================
# getopts check the options passed to the script
#===============================================================================
while getopts ':i:o:p:s:w:v:h' opt
do
case ${opt} in
i) infile="${OPTARG}"
histogram_overlay;;
o) infile="${OPTARG}"
rgb_overlay;;
p) infile="${OPTARG}"
rgb_parade;;
s) infile="${OPTARG}"
rgb_stacked;;
w) infile="${OPTARG}"
waveform_lowpass;;
v) infile="${OPTARG}"
vectorscope;;
h) usage;;
\?) usage "${INVALID_OPT_ERR} ${OPTARG}" 1>&2;;
:) usage "${INVALID_OPT_ERR} ${OPTARG} ${REQ_ARG_ERR}" 1>&2;;
esac
done
shift $((OPTIND-1))