forked from NapoleonWils0n/ffmpeg-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscopes
executable file
·147 lines (129 loc) · 2.67 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
#!/bin/sh
# ffplay video scopes
# script usage
usage()
{
[ -z "${1}" ] || echo "! ${1}"
echo "\
# ffplay video scopes
$(basename "$0") -i infile = histogram
$(basename "$0") -o infile = rgb overlay
$(basename "$0") -p infile = rgb parade
$(basename "$0") -s infile = rgb overlay and parade
$(basename "$0") -w infile = waveform
$(basename "$0") -v infile = vector scope
$(basename "$0") -h = help
"
exit 2
}
# error messages
NOTFILE_ERR='not a file'
INVALID_OPT_ERR='Invalid option:'
REQ_ARG_ERR='requires an argument'
WRONG_ARGS_ERR='wrong number of arguments passed to script'
NOT_MEDIA_FILE_ERR='is not a media file'
# if script is run arguments pass and check the options with getopts,
# else display script usage and exit
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"
# histogram overlay
histogram_overlay () {
ffplay "${infile}" \
-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}" \
-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}" \
-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}" \
-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}" \
-vf \
"split=2[a][b],
[b]waveform=f=lowpass:
s=ire:
g=green:
e=instant[bb],
[a][bb]vstack"
}
# vectorscope
vectorscope () {
ffplay "${infile}" \
-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 and validate options
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))