nodejs-audio-visualizer 4.2.3 → 4.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +70 -70
- package/dist/audio.d.ts +12 -12
- package/dist/audio.js +120 -120
- package/dist/beats.d.ts +19 -19
- package/dist/beats.js +43 -43
- package/dist/bpmEncoder.d.ts +14 -14
- package/dist/bpmEncoder.js +97 -97
- package/dist/config.d.ts +54 -54
- package/dist/config.js +299 -299
- package/dist/dsp.d.ts +16 -16
- package/dist/dsp.js +76 -76
- package/dist/highlight.d.ts +32 -32
- package/dist/highlight.js +325 -325
- package/dist/image.d.ts +79 -79
- package/dist/image.js +458 -458
- package/dist/index.d.ts +67 -67
- package/dist/index.js +470 -466
- package/dist/index.js.map +1 -1
- package/dist/video.d.ts +67 -64
- package/dist/video.js +317 -293
- package/dist/video.js.map +1 -1
- package/dist/waitForEventLoop.d.ts +1 -1
- package/dist/waitForEventLoop.js +5 -5
- package/package.json +61 -61
- package/src/audio.ts +120 -120
- package/src/beats.ts +68 -68
- package/src/bpmEncoder.ts +97 -97
- package/src/config.ts +382 -382
- package/src/dsp.ts +95 -95
- package/src/highlight.ts +284 -284
- package/src/image.ts +602 -602
- package/src/index.ts +610 -606
- package/src/tests/audio.test.ts +96 -96
- package/src/tests/config.test.ts +406 -406
- package/src/tests/dsp.test.ts +24 -24
- package/src/tests/highlight.test.ts +178 -178
- package/src/tests/image.test.ts +222 -222
- package/src/tests/index.test.ts +63 -63
- package/src/tests/video.test.ts +71 -71
- package/src/typings.d.ts +6 -6
- package/src/video.ts +403 -375
- package/src/waitForEventLoop.ts +2 -2
package/src/tests/config.test.ts
CHANGED
|
@@ -1,406 +1,406 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import { Config } from '../index';
|
|
4
|
-
import {
|
|
5
|
-
defaults,
|
|
6
|
-
getAudioFilePath,
|
|
7
|
-
getAudioAutoHighlight,
|
|
8
|
-
getAudioAutoHighlightCount,
|
|
9
|
-
getBackgroundImagePath,
|
|
10
|
-
getOutVideoPath,
|
|
11
|
-
getFPS,
|
|
12
|
-
getSpectrumWidthAbsolute,
|
|
13
|
-
getSpectrumHeightAbsolute,
|
|
14
|
-
getSpectrumXAbsolute,
|
|
15
|
-
getSpectrumYAbsolute,
|
|
16
|
-
getSpectrumColor,
|
|
17
|
-
getSpectrumOpacity,
|
|
18
|
-
getSpectrumOpacityParsed,
|
|
19
|
-
getFfmpeg_cfr,
|
|
20
|
-
getFfmpeg_preset,
|
|
21
|
-
getFrame_processing_delay,
|
|
22
|
-
checkIsValidRotationAlias,
|
|
23
|
-
checkIsPercentValue
|
|
24
|
-
} from '../config';
|
|
25
|
-
|
|
26
|
-
describe('config', function() {
|
|
27
|
-
it('getAudioFilePath', function() {
|
|
28
|
-
const result = getAudioFilePath({
|
|
29
|
-
audio: { path: 'test/path' }
|
|
30
|
-
} as Config);
|
|
31
|
-
const expected = path.resolve('test/path');
|
|
32
|
-
expect(result).equal(expected);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('getAudioAutoHighlight', function() {
|
|
36
|
-
expect(
|
|
37
|
-
getAudioAutoHighlight({ audio: { path: 'a.wav' } } as Config)
|
|
38
|
-
).equal(false);
|
|
39
|
-
expect(
|
|
40
|
-
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: false } } as Config)
|
|
41
|
-
).equal(false);
|
|
42
|
-
expect(
|
|
43
|
-
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: true } } as Config)
|
|
44
|
-
).equal(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('getAudioAutoHighlightCount', function() {
|
|
48
|
-
expect(
|
|
49
|
-
getAudioAutoHighlightCount({ audio: { path: 'a.wav' } } as Config)
|
|
50
|
-
).equal(1);
|
|
51
|
-
expect(
|
|
52
|
-
getAudioAutoHighlightCount({ audio: { path: 'a.wav', autoHighlightCount: 3 } } as Config)
|
|
53
|
-
).equal(3);
|
|
54
|
-
expect(
|
|
55
|
-
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 0 } } as Config)
|
|
56
|
-
).to.throw('Invalid audio.autoHighlightCount');
|
|
57
|
-
expect(
|
|
58
|
-
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 1.5 } } as Config)
|
|
59
|
-
).to.throw('Invalid audio.autoHighlightCount');
|
|
60
|
-
expect(
|
|
61
|
-
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: NaN } } as Config)
|
|
62
|
-
).to.throw('Invalid audio.autoHighlightCount');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('getBackgroundImagePath', function() {
|
|
66
|
-
const result = getBackgroundImagePath({
|
|
67
|
-
image: { path: 'test/path' }
|
|
68
|
-
} as Config);
|
|
69
|
-
const expected = path.resolve('test/path');
|
|
70
|
-
expect(result).equal(expected);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('getOutVideoPath', function() {
|
|
74
|
-
const result = getOutVideoPath({
|
|
75
|
-
outVideo: { path: 'test/path' }
|
|
76
|
-
} as Config);
|
|
77
|
-
const expected = path.resolve('test/path');
|
|
78
|
-
expect(result).equal(expected);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('getFPS', function() {
|
|
82
|
-
const result1 = getFPS({
|
|
83
|
-
outVideo: {}
|
|
84
|
-
} as Config);
|
|
85
|
-
expect(result1).equal(defaults.fps);
|
|
86
|
-
|
|
87
|
-
const result2 = getFPS({
|
|
88
|
-
outVideo: { fps: 15 }
|
|
89
|
-
} as Config);
|
|
90
|
-
expect(result2).equal(15);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('checkIsPercentValue', function() {
|
|
94
|
-
const result1 = checkIsPercentValue('69%');
|
|
95
|
-
expect(result1).equal(true);
|
|
96
|
-
|
|
97
|
-
const result2 = checkIsPercentValue('69');
|
|
98
|
-
expect(result2).equal(false);
|
|
99
|
-
|
|
100
|
-
const result3 = checkIsPercentValue('fake value');
|
|
101
|
-
expect(result3).equal(false);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('getSpectrumWidthAbsolute', function() {
|
|
105
|
-
const backgroundImageWidth = 1366;
|
|
106
|
-
const result1 = getSpectrumWidthAbsolute({
|
|
107
|
-
outVideo: {}
|
|
108
|
-
} as Config, backgroundImageWidth);
|
|
109
|
-
expect(result1).equal(
|
|
110
|
-
backgroundImageWidth * (parseInt(defaults.spectrumWidth) / 100)
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const result2 = getSpectrumWidthAbsolute({
|
|
114
|
-
outVideo: { spectrum: { width: 600 }}
|
|
115
|
-
} as Config, backgroundImageWidth);
|
|
116
|
-
expect(result2).equal(600);
|
|
117
|
-
|
|
118
|
-
const result3 = getSpectrumWidthAbsolute({
|
|
119
|
-
outVideo: { spectrum: { width: '69%' }}
|
|
120
|
-
} as Config, backgroundImageWidth);
|
|
121
|
-
expect(result3).equal(backgroundImageWidth * 0.69);
|
|
122
|
-
|
|
123
|
-
const result4 = getSpectrumWidthAbsolute.bind(
|
|
124
|
-
undefined,
|
|
125
|
-
{
|
|
126
|
-
outVideo: { spectrum: { width: '69' }}
|
|
127
|
-
} as Config,
|
|
128
|
-
backgroundImageWidth
|
|
129
|
-
);
|
|
130
|
-
expect(result4).to.throw('Invalid spectrum width value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
131
|
-
|
|
132
|
-
const result5 = getSpectrumWidthAbsolute.bind(
|
|
133
|
-
undefined,
|
|
134
|
-
{
|
|
135
|
-
outVideo: { spectrum: { width: 1 }}
|
|
136
|
-
} as Config,
|
|
137
|
-
backgroundImageWidth
|
|
138
|
-
);
|
|
139
|
-
expect(result5).to.throw('Spectrum width \'1\' is too small.');
|
|
140
|
-
|
|
141
|
-
const result6 = getSpectrumWidthAbsolute.bind(
|
|
142
|
-
undefined,
|
|
143
|
-
{
|
|
144
|
-
outVideo: { spectrum: { width: '1%' }}
|
|
145
|
-
} as Config,
|
|
146
|
-
backgroundImageWidth
|
|
147
|
-
);
|
|
148
|
-
expect(result6).to.throw('Spectrum width \'1%\' is too small.');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('getSpectrumHeightAbsolute', function() {
|
|
152
|
-
const backgroundImageHeight = 720;
|
|
153
|
-
const result1 = getSpectrumHeightAbsolute({
|
|
154
|
-
outVideo: {}
|
|
155
|
-
} as Config, backgroundImageHeight);
|
|
156
|
-
expect(result1).equal(160);
|
|
157
|
-
|
|
158
|
-
const result2 = getSpectrumHeightAbsolute({
|
|
159
|
-
outVideo: { spectrum: { height: 420 }}
|
|
160
|
-
} as Config, backgroundImageHeight);
|
|
161
|
-
expect(result2).equal(420);
|
|
162
|
-
|
|
163
|
-
const result3 = getSpectrumHeightAbsolute({
|
|
164
|
-
outVideo: { spectrum: { height: '69%' }}
|
|
165
|
-
} as Config, backgroundImageHeight);
|
|
166
|
-
expect(result3).equal(backgroundImageHeight * 0.69);
|
|
167
|
-
|
|
168
|
-
const result4 = getSpectrumHeightAbsolute.bind(
|
|
169
|
-
undefined,
|
|
170
|
-
{
|
|
171
|
-
outVideo: { spectrum: { height: '69' }}
|
|
172
|
-
} as Config,
|
|
173
|
-
backgroundImageHeight
|
|
174
|
-
);
|
|
175
|
-
expect(result4).to.throw('Invalid spectrum height value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('getSpectrumXAbsolute', function() {
|
|
179
|
-
const spectrumWidth = 420;
|
|
180
|
-
const backgroundImageWidth = 1366;
|
|
181
|
-
const result1 = getSpectrumXAbsolute(
|
|
182
|
-
{
|
|
183
|
-
outVideo: {},
|
|
184
|
-
} as Config,
|
|
185
|
-
spectrumWidth,
|
|
186
|
-
backgroundImageWidth
|
|
187
|
-
);
|
|
188
|
-
expect(result1).equal(
|
|
189
|
-
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
const result2 = getSpectrumXAbsolute(
|
|
193
|
-
{
|
|
194
|
-
outVideo: { spectrum: { x: 420 } }
|
|
195
|
-
} as Config,
|
|
196
|
-
spectrumWidth,
|
|
197
|
-
backgroundImageWidth
|
|
198
|
-
);
|
|
199
|
-
expect(result2).equal(420);
|
|
200
|
-
|
|
201
|
-
const result3 = getSpectrumXAbsolute(
|
|
202
|
-
{
|
|
203
|
-
outVideo: { spectrum: { x: 'left' } }
|
|
204
|
-
} as Config,
|
|
205
|
-
spectrumWidth,
|
|
206
|
-
backgroundImageWidth
|
|
207
|
-
);
|
|
208
|
-
expect(result3).equal(0);
|
|
209
|
-
|
|
210
|
-
const result4 = getSpectrumXAbsolute(
|
|
211
|
-
{
|
|
212
|
-
outVideo: { spectrum: { x: 'center' } }
|
|
213
|
-
} as Config,
|
|
214
|
-
spectrumWidth,
|
|
215
|
-
backgroundImageWidth
|
|
216
|
-
);
|
|
217
|
-
expect(result4).equal(
|
|
218
|
-
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
const result5 = getSpectrumXAbsolute(
|
|
222
|
-
{
|
|
223
|
-
outVideo: { spectrum: { x: 'right' } }
|
|
224
|
-
} as Config,
|
|
225
|
-
spectrumWidth,
|
|
226
|
-
backgroundImageWidth
|
|
227
|
-
);
|
|
228
|
-
expect(result5).equal(
|
|
229
|
-
1 * backgroundImageWidth - spectrumWidth
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
const result6 = getSpectrumXAbsolute.bind(
|
|
233
|
-
undefined,
|
|
234
|
-
{
|
|
235
|
-
outVideo: { spectrum: { x: 'sagewklkg' } }
|
|
236
|
-
} as unknown as Config,
|
|
237
|
-
spectrumWidth,
|
|
238
|
-
backgroundImageWidth
|
|
239
|
-
);
|
|
240
|
-
expect(result6).to.throw('Invalid spectrum x value: sagewklkg. Valid values: left, center, right, top, middle, bottom.');
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('getSpectrumYAbsolute', function() {
|
|
244
|
-
const spectrumHeight = 125;
|
|
245
|
-
const backgroundImageHeight = 721;
|
|
246
|
-
const result1 = getSpectrumYAbsolute(
|
|
247
|
-
{
|
|
248
|
-
outVideo: {},
|
|
249
|
-
} as Config,
|
|
250
|
-
spectrumHeight,
|
|
251
|
-
backgroundImageHeight
|
|
252
|
-
);
|
|
253
|
-
expect(result1).equal(
|
|
254
|
-
298
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
const result2 = getSpectrumYAbsolute(
|
|
258
|
-
{
|
|
259
|
-
outVideo: { spectrum: { y: 69 } }
|
|
260
|
-
} as Config,
|
|
261
|
-
spectrumHeight,
|
|
262
|
-
backgroundImageHeight
|
|
263
|
-
);
|
|
264
|
-
expect(result2).equal(69);
|
|
265
|
-
|
|
266
|
-
const result3 = getSpectrumYAbsolute(
|
|
267
|
-
{
|
|
268
|
-
outVideo: { spectrum: { y: 'top' } }
|
|
269
|
-
} as Config,
|
|
270
|
-
spectrumHeight,
|
|
271
|
-
backgroundImageHeight
|
|
272
|
-
);
|
|
273
|
-
expect(result3).equal(0);
|
|
274
|
-
|
|
275
|
-
const result4 = getSpectrumYAbsolute(
|
|
276
|
-
{
|
|
277
|
-
outVideo: { spectrum: { y: 'middle' } }
|
|
278
|
-
} as Config,
|
|
279
|
-
spectrumHeight,
|
|
280
|
-
backgroundImageHeight
|
|
281
|
-
);
|
|
282
|
-
expect(result4).equal(
|
|
283
|
-
0.5 * backgroundImageHeight - spectrumHeight / 2
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
const result5 = getSpectrumYAbsolute(
|
|
287
|
-
{
|
|
288
|
-
outVideo: { spectrum: { y: 'bottom' } }
|
|
289
|
-
} as Config,
|
|
290
|
-
spectrumHeight,
|
|
291
|
-
backgroundImageHeight
|
|
292
|
-
);
|
|
293
|
-
expect(result5).equal(
|
|
294
|
-
1 * backgroundImageHeight - spectrumHeight
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const result6 = getSpectrumYAbsolute.bind(
|
|
298
|
-
undefined,
|
|
299
|
-
{
|
|
300
|
-
outVideo: { spectrum: { y: 'asokosckm' } }
|
|
301
|
-
} as unknown as Config,
|
|
302
|
-
spectrumHeight,
|
|
303
|
-
backgroundImageHeight
|
|
304
|
-
);
|
|
305
|
-
expect(result6).to.throw('Invalid spectrum y value: asokosckm. Valid values: left, center, right, top, middle, bottom.');
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('getSpectrumColor', function() {
|
|
309
|
-
const result1 = getSpectrumColor({
|
|
310
|
-
outVideo: {}
|
|
311
|
-
} as Config);
|
|
312
|
-
expect(result1).equal(undefined);
|
|
313
|
-
|
|
314
|
-
const result2 = getSpectrumColor({
|
|
315
|
-
outVideo: { spectrum: { color: '#cccc99' } }
|
|
316
|
-
} as Config);
|
|
317
|
-
expect(result2).equal('#cccc99');
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('getSpectrumOpacity', function() {
|
|
321
|
-
const result1 = getSpectrumOpacity({
|
|
322
|
-
outVideo: {}
|
|
323
|
-
} as Config);
|
|
324
|
-
expect(result1).equal(defaults.spectrumOpacity);
|
|
325
|
-
|
|
326
|
-
const result2 = getSpectrumOpacity({
|
|
327
|
-
outVideo: { spectrum: { opacity: '69%' } }
|
|
328
|
-
} as Config);
|
|
329
|
-
expect(result2).equal('69%');
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it('getSpectrumOpacityParsed', function() {
|
|
333
|
-
const result1 = getSpectrumOpacityParsed({
|
|
334
|
-
outVideo: {}
|
|
335
|
-
} as Config);
|
|
336
|
-
expect(result1).equal(parseInt(defaults.spectrumOpacity) / 100);
|
|
337
|
-
|
|
338
|
-
const result2 = getSpectrumOpacityParsed({
|
|
339
|
-
outVideo: { spectrum: { opacity: '69%' } }
|
|
340
|
-
} as Config);
|
|
341
|
-
expect(result2).equal(0.69);
|
|
342
|
-
|
|
343
|
-
const result3 = getSpectrumOpacityParsed.bind(
|
|
344
|
-
undefined,
|
|
345
|
-
{
|
|
346
|
-
outVideo: { spectrum: { opacity: 'fake value' } }
|
|
347
|
-
} as Config
|
|
348
|
-
);
|
|
349
|
-
expect(result3).to.throw('Invalid spectrum opacity value: \'fake value\'. Use string percent value, for example \'80%\'.');
|
|
350
|
-
|
|
351
|
-
const result4 = getSpectrumOpacityParsed.bind(
|
|
352
|
-
undefined,
|
|
353
|
-
{
|
|
354
|
-
outVideo: { spectrum: { opacity: '103%' } }
|
|
355
|
-
} as Config
|
|
356
|
-
);
|
|
357
|
-
expect(result4).to.throw('Invalid spectrum opacity value: \'103%\'. Percent values must be in range from \'0%\' to \'100%\'.');
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it('getFfmpeg_cfr', function() {
|
|
361
|
-
const result1 = getFfmpeg_cfr({
|
|
362
|
-
tweaks: {}
|
|
363
|
-
} as Config);
|
|
364
|
-
expect(result1).equal(undefined);
|
|
365
|
-
|
|
366
|
-
const result2 = getFfmpeg_cfr({
|
|
367
|
-
tweaks: { ffmpeg_cfr: '69' }
|
|
368
|
-
} as Config);
|
|
369
|
-
expect(result2).equal('69');
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it('getFfmpeg_preset', function() {
|
|
373
|
-
const result1 = getFfmpeg_preset({
|
|
374
|
-
tweaks: {}
|
|
375
|
-
} as Config);
|
|
376
|
-
expect(result1).equal(undefined);
|
|
377
|
-
|
|
378
|
-
const result2 = getFfmpeg_preset({
|
|
379
|
-
tweaks: { ffmpeg_preset: 'quality' }
|
|
380
|
-
} as Config);
|
|
381
|
-
expect(result2).equal('quality');
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it('getFrame_processing_delay', function() {
|
|
385
|
-
const result1 = getFrame_processing_delay({
|
|
386
|
-
tweaks: {}
|
|
387
|
-
} as Config);
|
|
388
|
-
expect(result1).equal(undefined);
|
|
389
|
-
|
|
390
|
-
const result2 = getFrame_processing_delay({
|
|
391
|
-
tweaks: { frame_processing_delay: 420 }
|
|
392
|
-
} as Config);
|
|
393
|
-
expect(result2).equal(420);
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('checkIsValidRotationAlias', function() {
|
|
397
|
-
const result1 = checkIsValidRotationAlias('up');
|
|
398
|
-
expect(result1).equal(true);
|
|
399
|
-
|
|
400
|
-
const result2 = checkIsValidRotationAlias('down');
|
|
401
|
-
expect(result2).equal(true);
|
|
402
|
-
|
|
403
|
-
const result3 = checkIsValidRotationAlias('fake value');
|
|
404
|
-
expect(result3).equal(false);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { Config } from '../index';
|
|
4
|
+
import {
|
|
5
|
+
defaults,
|
|
6
|
+
getAudioFilePath,
|
|
7
|
+
getAudioAutoHighlight,
|
|
8
|
+
getAudioAutoHighlightCount,
|
|
9
|
+
getBackgroundImagePath,
|
|
10
|
+
getOutVideoPath,
|
|
11
|
+
getFPS,
|
|
12
|
+
getSpectrumWidthAbsolute,
|
|
13
|
+
getSpectrumHeightAbsolute,
|
|
14
|
+
getSpectrumXAbsolute,
|
|
15
|
+
getSpectrumYAbsolute,
|
|
16
|
+
getSpectrumColor,
|
|
17
|
+
getSpectrumOpacity,
|
|
18
|
+
getSpectrumOpacityParsed,
|
|
19
|
+
getFfmpeg_cfr,
|
|
20
|
+
getFfmpeg_preset,
|
|
21
|
+
getFrame_processing_delay,
|
|
22
|
+
checkIsValidRotationAlias,
|
|
23
|
+
checkIsPercentValue
|
|
24
|
+
} from '../config';
|
|
25
|
+
|
|
26
|
+
describe('config', function() {
|
|
27
|
+
it('getAudioFilePath', function() {
|
|
28
|
+
const result = getAudioFilePath({
|
|
29
|
+
audio: { path: 'test/path' }
|
|
30
|
+
} as Config);
|
|
31
|
+
const expected = path.resolve('test/path');
|
|
32
|
+
expect(result).equal(expected);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('getAudioAutoHighlight', function() {
|
|
36
|
+
expect(
|
|
37
|
+
getAudioAutoHighlight({ audio: { path: 'a.wav' } } as Config)
|
|
38
|
+
).equal(false);
|
|
39
|
+
expect(
|
|
40
|
+
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: false } } as Config)
|
|
41
|
+
).equal(false);
|
|
42
|
+
expect(
|
|
43
|
+
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: true } } as Config)
|
|
44
|
+
).equal(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('getAudioAutoHighlightCount', function() {
|
|
48
|
+
expect(
|
|
49
|
+
getAudioAutoHighlightCount({ audio: { path: 'a.wav' } } as Config)
|
|
50
|
+
).equal(1);
|
|
51
|
+
expect(
|
|
52
|
+
getAudioAutoHighlightCount({ audio: { path: 'a.wav', autoHighlightCount: 3 } } as Config)
|
|
53
|
+
).equal(3);
|
|
54
|
+
expect(
|
|
55
|
+
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 0 } } as Config)
|
|
56
|
+
).to.throw('Invalid audio.autoHighlightCount');
|
|
57
|
+
expect(
|
|
58
|
+
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 1.5 } } as Config)
|
|
59
|
+
).to.throw('Invalid audio.autoHighlightCount');
|
|
60
|
+
expect(
|
|
61
|
+
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: NaN } } as Config)
|
|
62
|
+
).to.throw('Invalid audio.autoHighlightCount');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('getBackgroundImagePath', function() {
|
|
66
|
+
const result = getBackgroundImagePath({
|
|
67
|
+
image: { path: 'test/path' }
|
|
68
|
+
} as Config);
|
|
69
|
+
const expected = path.resolve('test/path');
|
|
70
|
+
expect(result).equal(expected);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('getOutVideoPath', function() {
|
|
74
|
+
const result = getOutVideoPath({
|
|
75
|
+
outVideo: { path: 'test/path' }
|
|
76
|
+
} as Config);
|
|
77
|
+
const expected = path.resolve('test/path');
|
|
78
|
+
expect(result).equal(expected);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('getFPS', function() {
|
|
82
|
+
const result1 = getFPS({
|
|
83
|
+
outVideo: {}
|
|
84
|
+
} as Config);
|
|
85
|
+
expect(result1).equal(defaults.fps);
|
|
86
|
+
|
|
87
|
+
const result2 = getFPS({
|
|
88
|
+
outVideo: { fps: 15 }
|
|
89
|
+
} as Config);
|
|
90
|
+
expect(result2).equal(15);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('checkIsPercentValue', function() {
|
|
94
|
+
const result1 = checkIsPercentValue('69%');
|
|
95
|
+
expect(result1).equal(true);
|
|
96
|
+
|
|
97
|
+
const result2 = checkIsPercentValue('69');
|
|
98
|
+
expect(result2).equal(false);
|
|
99
|
+
|
|
100
|
+
const result3 = checkIsPercentValue('fake value');
|
|
101
|
+
expect(result3).equal(false);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('getSpectrumWidthAbsolute', function() {
|
|
105
|
+
const backgroundImageWidth = 1366;
|
|
106
|
+
const result1 = getSpectrumWidthAbsolute({
|
|
107
|
+
outVideo: {}
|
|
108
|
+
} as Config, backgroundImageWidth);
|
|
109
|
+
expect(result1).equal(
|
|
110
|
+
backgroundImageWidth * (parseInt(defaults.spectrumWidth) / 100)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const result2 = getSpectrumWidthAbsolute({
|
|
114
|
+
outVideo: { spectrum: { width: 600 }}
|
|
115
|
+
} as Config, backgroundImageWidth);
|
|
116
|
+
expect(result2).equal(600);
|
|
117
|
+
|
|
118
|
+
const result3 = getSpectrumWidthAbsolute({
|
|
119
|
+
outVideo: { spectrum: { width: '69%' }}
|
|
120
|
+
} as Config, backgroundImageWidth);
|
|
121
|
+
expect(result3).equal(backgroundImageWidth * 0.69);
|
|
122
|
+
|
|
123
|
+
const result4 = getSpectrumWidthAbsolute.bind(
|
|
124
|
+
undefined,
|
|
125
|
+
{
|
|
126
|
+
outVideo: { spectrum: { width: '69' }}
|
|
127
|
+
} as Config,
|
|
128
|
+
backgroundImageWidth
|
|
129
|
+
);
|
|
130
|
+
expect(result4).to.throw('Invalid spectrum width value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
131
|
+
|
|
132
|
+
const result5 = getSpectrumWidthAbsolute.bind(
|
|
133
|
+
undefined,
|
|
134
|
+
{
|
|
135
|
+
outVideo: { spectrum: { width: 1 }}
|
|
136
|
+
} as Config,
|
|
137
|
+
backgroundImageWidth
|
|
138
|
+
);
|
|
139
|
+
expect(result5).to.throw('Spectrum width \'1\' is too small.');
|
|
140
|
+
|
|
141
|
+
const result6 = getSpectrumWidthAbsolute.bind(
|
|
142
|
+
undefined,
|
|
143
|
+
{
|
|
144
|
+
outVideo: { spectrum: { width: '1%' }}
|
|
145
|
+
} as Config,
|
|
146
|
+
backgroundImageWidth
|
|
147
|
+
);
|
|
148
|
+
expect(result6).to.throw('Spectrum width \'1%\' is too small.');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('getSpectrumHeightAbsolute', function() {
|
|
152
|
+
const backgroundImageHeight = 720;
|
|
153
|
+
const result1 = getSpectrumHeightAbsolute({
|
|
154
|
+
outVideo: {}
|
|
155
|
+
} as Config, backgroundImageHeight);
|
|
156
|
+
expect(result1).equal(160);
|
|
157
|
+
|
|
158
|
+
const result2 = getSpectrumHeightAbsolute({
|
|
159
|
+
outVideo: { spectrum: { height: 420 }}
|
|
160
|
+
} as Config, backgroundImageHeight);
|
|
161
|
+
expect(result2).equal(420);
|
|
162
|
+
|
|
163
|
+
const result3 = getSpectrumHeightAbsolute({
|
|
164
|
+
outVideo: { spectrum: { height: '69%' }}
|
|
165
|
+
} as Config, backgroundImageHeight);
|
|
166
|
+
expect(result3).equal(backgroundImageHeight * 0.69);
|
|
167
|
+
|
|
168
|
+
const result4 = getSpectrumHeightAbsolute.bind(
|
|
169
|
+
undefined,
|
|
170
|
+
{
|
|
171
|
+
outVideo: { spectrum: { height: '69' }}
|
|
172
|
+
} as Config,
|
|
173
|
+
backgroundImageHeight
|
|
174
|
+
);
|
|
175
|
+
expect(result4).to.throw('Invalid spectrum height value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('getSpectrumXAbsolute', function() {
|
|
179
|
+
const spectrumWidth = 420;
|
|
180
|
+
const backgroundImageWidth = 1366;
|
|
181
|
+
const result1 = getSpectrumXAbsolute(
|
|
182
|
+
{
|
|
183
|
+
outVideo: {},
|
|
184
|
+
} as Config,
|
|
185
|
+
spectrumWidth,
|
|
186
|
+
backgroundImageWidth
|
|
187
|
+
);
|
|
188
|
+
expect(result1).equal(
|
|
189
|
+
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const result2 = getSpectrumXAbsolute(
|
|
193
|
+
{
|
|
194
|
+
outVideo: { spectrum: { x: 420 } }
|
|
195
|
+
} as Config,
|
|
196
|
+
spectrumWidth,
|
|
197
|
+
backgroundImageWidth
|
|
198
|
+
);
|
|
199
|
+
expect(result2).equal(420);
|
|
200
|
+
|
|
201
|
+
const result3 = getSpectrumXAbsolute(
|
|
202
|
+
{
|
|
203
|
+
outVideo: { spectrum: { x: 'left' } }
|
|
204
|
+
} as Config,
|
|
205
|
+
spectrumWidth,
|
|
206
|
+
backgroundImageWidth
|
|
207
|
+
);
|
|
208
|
+
expect(result3).equal(0);
|
|
209
|
+
|
|
210
|
+
const result4 = getSpectrumXAbsolute(
|
|
211
|
+
{
|
|
212
|
+
outVideo: { spectrum: { x: 'center' } }
|
|
213
|
+
} as Config,
|
|
214
|
+
spectrumWidth,
|
|
215
|
+
backgroundImageWidth
|
|
216
|
+
);
|
|
217
|
+
expect(result4).equal(
|
|
218
|
+
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const result5 = getSpectrumXAbsolute(
|
|
222
|
+
{
|
|
223
|
+
outVideo: { spectrum: { x: 'right' } }
|
|
224
|
+
} as Config,
|
|
225
|
+
spectrumWidth,
|
|
226
|
+
backgroundImageWidth
|
|
227
|
+
);
|
|
228
|
+
expect(result5).equal(
|
|
229
|
+
1 * backgroundImageWidth - spectrumWidth
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const result6 = getSpectrumXAbsolute.bind(
|
|
233
|
+
undefined,
|
|
234
|
+
{
|
|
235
|
+
outVideo: { spectrum: { x: 'sagewklkg' } }
|
|
236
|
+
} as unknown as Config,
|
|
237
|
+
spectrumWidth,
|
|
238
|
+
backgroundImageWidth
|
|
239
|
+
);
|
|
240
|
+
expect(result6).to.throw('Invalid spectrum x value: sagewklkg. Valid values: left, center, right, top, middle, bottom.');
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('getSpectrumYAbsolute', function() {
|
|
244
|
+
const spectrumHeight = 125;
|
|
245
|
+
const backgroundImageHeight = 721;
|
|
246
|
+
const result1 = getSpectrumYAbsolute(
|
|
247
|
+
{
|
|
248
|
+
outVideo: {},
|
|
249
|
+
} as Config,
|
|
250
|
+
spectrumHeight,
|
|
251
|
+
backgroundImageHeight
|
|
252
|
+
);
|
|
253
|
+
expect(result1).equal(
|
|
254
|
+
298
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
const result2 = getSpectrumYAbsolute(
|
|
258
|
+
{
|
|
259
|
+
outVideo: { spectrum: { y: 69 } }
|
|
260
|
+
} as Config,
|
|
261
|
+
spectrumHeight,
|
|
262
|
+
backgroundImageHeight
|
|
263
|
+
);
|
|
264
|
+
expect(result2).equal(69);
|
|
265
|
+
|
|
266
|
+
const result3 = getSpectrumYAbsolute(
|
|
267
|
+
{
|
|
268
|
+
outVideo: { spectrum: { y: 'top' } }
|
|
269
|
+
} as Config,
|
|
270
|
+
spectrumHeight,
|
|
271
|
+
backgroundImageHeight
|
|
272
|
+
);
|
|
273
|
+
expect(result3).equal(0);
|
|
274
|
+
|
|
275
|
+
const result4 = getSpectrumYAbsolute(
|
|
276
|
+
{
|
|
277
|
+
outVideo: { spectrum: { y: 'middle' } }
|
|
278
|
+
} as Config,
|
|
279
|
+
spectrumHeight,
|
|
280
|
+
backgroundImageHeight
|
|
281
|
+
);
|
|
282
|
+
expect(result4).equal(
|
|
283
|
+
0.5 * backgroundImageHeight - spectrumHeight / 2
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
const result5 = getSpectrumYAbsolute(
|
|
287
|
+
{
|
|
288
|
+
outVideo: { spectrum: { y: 'bottom' } }
|
|
289
|
+
} as Config,
|
|
290
|
+
spectrumHeight,
|
|
291
|
+
backgroundImageHeight
|
|
292
|
+
);
|
|
293
|
+
expect(result5).equal(
|
|
294
|
+
1 * backgroundImageHeight - spectrumHeight
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const result6 = getSpectrumYAbsolute.bind(
|
|
298
|
+
undefined,
|
|
299
|
+
{
|
|
300
|
+
outVideo: { spectrum: { y: 'asokosckm' } }
|
|
301
|
+
} as unknown as Config,
|
|
302
|
+
spectrumHeight,
|
|
303
|
+
backgroundImageHeight
|
|
304
|
+
);
|
|
305
|
+
expect(result6).to.throw('Invalid spectrum y value: asokosckm. Valid values: left, center, right, top, middle, bottom.');
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('getSpectrumColor', function() {
|
|
309
|
+
const result1 = getSpectrumColor({
|
|
310
|
+
outVideo: {}
|
|
311
|
+
} as Config);
|
|
312
|
+
expect(result1).equal(undefined);
|
|
313
|
+
|
|
314
|
+
const result2 = getSpectrumColor({
|
|
315
|
+
outVideo: { spectrum: { color: '#cccc99' } }
|
|
316
|
+
} as Config);
|
|
317
|
+
expect(result2).equal('#cccc99');
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('getSpectrumOpacity', function() {
|
|
321
|
+
const result1 = getSpectrumOpacity({
|
|
322
|
+
outVideo: {}
|
|
323
|
+
} as Config);
|
|
324
|
+
expect(result1).equal(defaults.spectrumOpacity);
|
|
325
|
+
|
|
326
|
+
const result2 = getSpectrumOpacity({
|
|
327
|
+
outVideo: { spectrum: { opacity: '69%' } }
|
|
328
|
+
} as Config);
|
|
329
|
+
expect(result2).equal('69%');
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('getSpectrumOpacityParsed', function() {
|
|
333
|
+
const result1 = getSpectrumOpacityParsed({
|
|
334
|
+
outVideo: {}
|
|
335
|
+
} as Config);
|
|
336
|
+
expect(result1).equal(parseInt(defaults.spectrumOpacity) / 100);
|
|
337
|
+
|
|
338
|
+
const result2 = getSpectrumOpacityParsed({
|
|
339
|
+
outVideo: { spectrum: { opacity: '69%' } }
|
|
340
|
+
} as Config);
|
|
341
|
+
expect(result2).equal(0.69);
|
|
342
|
+
|
|
343
|
+
const result3 = getSpectrumOpacityParsed.bind(
|
|
344
|
+
undefined,
|
|
345
|
+
{
|
|
346
|
+
outVideo: { spectrum: { opacity: 'fake value' } }
|
|
347
|
+
} as Config
|
|
348
|
+
);
|
|
349
|
+
expect(result3).to.throw('Invalid spectrum opacity value: \'fake value\'. Use string percent value, for example \'80%\'.');
|
|
350
|
+
|
|
351
|
+
const result4 = getSpectrumOpacityParsed.bind(
|
|
352
|
+
undefined,
|
|
353
|
+
{
|
|
354
|
+
outVideo: { spectrum: { opacity: '103%' } }
|
|
355
|
+
} as Config
|
|
356
|
+
);
|
|
357
|
+
expect(result4).to.throw('Invalid spectrum opacity value: \'103%\'. Percent values must be in range from \'0%\' to \'100%\'.');
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('getFfmpeg_cfr', function() {
|
|
361
|
+
const result1 = getFfmpeg_cfr({
|
|
362
|
+
tweaks: {}
|
|
363
|
+
} as Config);
|
|
364
|
+
expect(result1).equal(undefined);
|
|
365
|
+
|
|
366
|
+
const result2 = getFfmpeg_cfr({
|
|
367
|
+
tweaks: { ffmpeg_cfr: '69' }
|
|
368
|
+
} as Config);
|
|
369
|
+
expect(result2).equal('69');
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('getFfmpeg_preset', function() {
|
|
373
|
+
const result1 = getFfmpeg_preset({
|
|
374
|
+
tweaks: {}
|
|
375
|
+
} as Config);
|
|
376
|
+
expect(result1).equal(undefined);
|
|
377
|
+
|
|
378
|
+
const result2 = getFfmpeg_preset({
|
|
379
|
+
tweaks: { ffmpeg_preset: 'quality' }
|
|
380
|
+
} as Config);
|
|
381
|
+
expect(result2).equal('quality');
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('getFrame_processing_delay', function() {
|
|
385
|
+
const result1 = getFrame_processing_delay({
|
|
386
|
+
tweaks: {}
|
|
387
|
+
} as Config);
|
|
388
|
+
expect(result1).equal(undefined);
|
|
389
|
+
|
|
390
|
+
const result2 = getFrame_processing_delay({
|
|
391
|
+
tweaks: { frame_processing_delay: 420 }
|
|
392
|
+
} as Config);
|
|
393
|
+
expect(result2).equal(420);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it('checkIsValidRotationAlias', function() {
|
|
397
|
+
const result1 = checkIsValidRotationAlias('up');
|
|
398
|
+
expect(result1).equal(true);
|
|
399
|
+
|
|
400
|
+
const result2 = checkIsValidRotationAlias('down');
|
|
401
|
+
expect(result2).equal(true);
|
|
402
|
+
|
|
403
|
+
const result3 = checkIsValidRotationAlias('fake value');
|
|
404
|
+
expect(result3).equal(false);
|
|
405
|
+
});
|
|
406
|
+
});
|