-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadrawgraph.js
259 lines (239 loc) · 4.81 KB
/
adrawgraph.js
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
256
257
258
259
const addFilter = require('./utils').addFilter;
const registerFilter = require('./utils').registerFilter;
/**
* Augment FfmpegCommand with the adrawgraph function.
*
*
* @example
* ffmpeg().adrawgraph()
* ... // call filter configuration functions
* .build() // end filter configuration
* ...
* .applyFilters() // called once all filters have been configured
*
* @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor.
* @return {FfmpegCommand} The ffmpegCommand augmented with the adrawgraph function.
*/
function adrawgraph(ffmpegCommand) {
registerFilter(ffmpegCommand, 'adrawgraph', function() {
return new AdrawgraphFilter(this);
});
return ffmpegCommand;
}
/**
* Class exposing methods to configure the vstack filter in a builder pattern way.
*
* See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description
* of each configuration option.
*/
class AdrawgraphFilter {
/**
* @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor.
*/
constructor (ffmpeg) {
this.ffmpeg = ffmpeg;
AdrawgraphFilter.prototype.withM1 = this.m1;
AdrawgraphFilter.prototype.withFg1 = this.fg1;
AdrawgraphFilter.prototype.withM2 = this.m2;
AdrawgraphFilter.prototype.withFg2 = this.fg2;
AdrawgraphFilter.prototype.withM3 = this.m3;
AdrawgraphFilter.prototype.withFg3 = this.fg3;
AdrawgraphFilter.prototype.withM4 = this.m4;
AdrawgraphFilter.prototype.withFg4 = this.fg4;
AdrawgraphFilter.prototype.withMin = this.min;
AdrawgraphFilter.prototype.withMax = this.max;
AdrawgraphFilter.prototype.withBg = this.bg;
AdrawgraphFilter.prototype.withMode = this.mode;
AdrawgraphFilter.prototype.withSlide = this.slide;
AdrawgraphFilter.prototype.withSize = this.size;
}
/**
* Set 1st frame metadata key from which metadata values will be used to draw a graph.
*
*
* @param val
*/
m1(val) {
this._m1 = val;
return this;
}
/**
* Set 1st foreground color expression.
*
*
* @param val
*/
fg1(val) {
this._fg1 = val;
return this;
}
/**
* Set 2nd frame metadata key from which metadata values will be used to draw a graph.
*
*
* @param val
*/
m2(val) {
this._m2 = val;
return this;
}
/**
* Set 2nd foreground color expression.
*
*
* @param val
*/
fg2(val) {
this._fg2 = val;
return this;
}
/**
* Set 3rd frame metadata key from which metadata values will be used to draw a graph.
*
*
* @param val
*/
m3(val) {
this._m3 = val;
return this;
}
/**
* Set 3rd foreground color expression.
*
*
* @param val
*/
fg3(val) {
this._fg3 = val;
return this;
}
/**
* Set 4th frame metadata key from which metadata values will be used to draw a graph.
*
*
* @param val
*/
m4(val) {
this._m4 = val;
return this;
}
/**
* Set 4th foreground color expression.
*
*
* @param val
*/
fg4(val) {
this._fg4 = val;
return this;
}
/**
* Set minimal value of metadata value.
*
*
* @param val
*/
min(val) {
this._min = val;
return this;
}
/**
* Set maximal value of metadata value.
*
*
* @param val
*/
max(val) {
this._max = val;
return this;
}
/**
* Set graph background color. Default is white.
*
*
* @param val
*/
bg(val) {
this._bg = val;
return this;
}
/**
*
* @param val
*/
mode(val) {
this._mode = val;
return this;
}
/**
*
* @param val
*/
slide(val) {
this._slide = val;
return this;
}
/**
*
* @param val
*/
size(val) {
this._size = val;
return this;
}
/**
* Creates this filter configuration and registers it in the ffmpeg instance.
* @return {ffmpegCommand} The ffmpeg instance.
*/
build() {
let opt = {};
if (this._m1) {
opt['m1'] = this._m1;
}
if (this._fg1) {
opt['fg1'] = this._fg1;
}
if (this._m2) {
opt['m2'] = this._m2;
}
if (this._fg2) {
opt['fg2'] = this._fg2;
}
if (this._m3) {
opt['m3'] = this._m3;
}
if (this._fg3) {
opt['fg3'] = this._fg3;
}
if (this._m4) {
opt['m4'] = this._m4;
}
if (this._fg4) {
opt['fg4'] = this._fg4;
}
if (this._min) {
opt['min'] = this._min;
}
if (this._max) {
opt['max'] = this._max;
}
if (this._bg) {
opt['bg'] = this._bg;
}
if (this._mode) {
opt['mode'] = this._mode;
}
if (this._slide) {
opt['slide'] = this._slide;
}
if (this._size) {
opt['size'] = this._size;
}
addFilter(this.ffmpeg, {
filter: 'adrawgraph',
options: opt
});
return this.ffmpeg;
}
}
module.exports.adrawgraph = adrawgraph;