nodejs-audio-visualizer 4.3.7 → 4.3.8
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 +75 -75
- 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 +67 -67
- package/dist/config.js +356 -356
- 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 +72 -72
- package/dist/index.js +536 -541
- package/dist/index.js.map +1 -1
- package/dist/subtitleConvert.d.ts +3 -3
- package/dist/subtitleConvert.js +61 -61
- package/dist/video.d.ts +72 -72
- package/dist/video.js +338 -338
- 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 +462 -462
- package/src/dsp.ts +95 -95
- package/src/highlight.ts +284 -284
- package/src/image.ts +602 -602
- package/src/index.ts +678 -678
- package/src/subtitleConvert.ts +63 -63
- package/src/tests/audio.test.ts +96 -96
- package/src/tests/config.test.ts +475 -475
- 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/subtitleConvert.test.ts +23 -23
- package/src/tests/video.test.ts +138 -138
- package/src/typings.d.ts +6 -6
- package/src/video.ts +437 -437
- package/src/waitForEventLoop.ts +2 -2
package/src/tests/config.test.ts
CHANGED
|
@@ -1,475 +1,475 @@
|
|
|
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
|
-
getSubtitleRenderSpec,
|
|
12
|
-
subtitleAlignmentToAss,
|
|
13
|
-
getFPS,
|
|
14
|
-
getSpectrumWidthAbsolute,
|
|
15
|
-
getSpectrumHeightAbsolute,
|
|
16
|
-
getSpectrumXAbsolute,
|
|
17
|
-
getSpectrumYAbsolute,
|
|
18
|
-
getSpectrumColor,
|
|
19
|
-
getSpectrumOpacity,
|
|
20
|
-
getSpectrumOpacityParsed,
|
|
21
|
-
getFfmpeg_cfr,
|
|
22
|
-
getFfmpeg_preset,
|
|
23
|
-
getFrame_processing_delay,
|
|
24
|
-
checkIsValidRotationAlias,
|
|
25
|
-
checkIsPercentValue
|
|
26
|
-
} from '../config';
|
|
27
|
-
|
|
28
|
-
describe('config', function() {
|
|
29
|
-
it('getAudioFilePath', function() {
|
|
30
|
-
const result = getAudioFilePath({
|
|
31
|
-
audio: { path: 'test/path' }
|
|
32
|
-
} as Config);
|
|
33
|
-
const expected = path.resolve('test/path');
|
|
34
|
-
expect(result).equal(expected);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('getAudioAutoHighlight', function() {
|
|
38
|
-
expect(
|
|
39
|
-
getAudioAutoHighlight({ audio: { path: 'a.wav' } } as Config)
|
|
40
|
-
).equal(false);
|
|
41
|
-
expect(
|
|
42
|
-
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: false } } as Config)
|
|
43
|
-
).equal(false);
|
|
44
|
-
expect(
|
|
45
|
-
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: true } } as Config)
|
|
46
|
-
).equal(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('getAudioAutoHighlightCount', function() {
|
|
50
|
-
expect(
|
|
51
|
-
getAudioAutoHighlightCount({ audio: { path: 'a.wav' } } as Config)
|
|
52
|
-
).equal(1);
|
|
53
|
-
expect(
|
|
54
|
-
getAudioAutoHighlightCount({ audio: { path: 'a.wav', autoHighlightCount: 3 } } as Config)
|
|
55
|
-
).equal(3);
|
|
56
|
-
expect(
|
|
57
|
-
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 0 } } as Config)
|
|
58
|
-
).to.throw('Invalid audio.autoHighlightCount');
|
|
59
|
-
expect(
|
|
60
|
-
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 1.5 } } as Config)
|
|
61
|
-
).to.throw('Invalid audio.autoHighlightCount');
|
|
62
|
-
expect(
|
|
63
|
-
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: NaN } } as Config)
|
|
64
|
-
).to.throw('Invalid audio.autoHighlightCount');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('getBackgroundImagePath', function() {
|
|
68
|
-
const result = getBackgroundImagePath({
|
|
69
|
-
image: { path: 'test/path' }
|
|
70
|
-
} as Config);
|
|
71
|
-
const expected = path.resolve('test/path');
|
|
72
|
-
expect(result).equal(expected);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('getOutVideoPath', function() {
|
|
76
|
-
const result = getOutVideoPath({
|
|
77
|
-
outVideo: { path: 'test/path' }
|
|
78
|
-
} as Config);
|
|
79
|
-
const expected = path.resolve('test/path');
|
|
80
|
-
expect(result).equal(expected);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('getSubtitleRenderSpec', function() {
|
|
84
|
-
expect(
|
|
85
|
-
getSubtitleRenderSpec({ outVideo: {} } as Config)
|
|
86
|
-
).equal(undefined);
|
|
87
|
-
|
|
88
|
-
expect(
|
|
89
|
-
getSubtitleRenderSpec({
|
|
90
|
-
outVideo: { subtitles: '1\n00:00:00,000 --> 00:00:01,000\nTest' }
|
|
91
|
-
} as Config)
|
|
92
|
-
).deep.equal({
|
|
93
|
-
source: { kind: 'inline', text: '1\n00:00:00,000 --> 00:00:01,000\nTest' },
|
|
94
|
-
alignment: 'bottom',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
expect(
|
|
98
|
-
getSubtitleRenderSpec({
|
|
99
|
-
outVideo: {
|
|
100
|
-
subtitles: { rawContent: '1\n00:00:00,000 --> 00:00:01,000\nHi', alignment: 'top' }
|
|
101
|
-
}
|
|
102
|
-
} as Config)
|
|
103
|
-
).deep.equal({
|
|
104
|
-
source: { kind: 'inline', text: '1\n00:00:00,000 --> 00:00:01,000\nHi' },
|
|
105
|
-
alignment: 'top',
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
expect(
|
|
109
|
-
getSubtitleRenderSpec({
|
|
110
|
-
outVideo: { subtitles: { path: 'media/sub.srt' } }
|
|
111
|
-
} as Config)
|
|
112
|
-
).deep.equal({
|
|
113
|
-
source: { kind: 'file', path: path.resolve('media/sub.srt') },
|
|
114
|
-
alignment: 'bottom',
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
expect(
|
|
118
|
-
getSubtitleRenderSpec({ outVideo: { subtitles: {} } } as Config)
|
|
119
|
-
).equal(undefined);
|
|
120
|
-
|
|
121
|
-
expect(
|
|
122
|
-
getSubtitleRenderSpec.bind(undefined, {
|
|
123
|
-
outVideo: { subtitles: '' }
|
|
124
|
-
} as unknown as Config)
|
|
125
|
-
).to.throw('Invalid outVideo.subtitles: expected non-empty string content');
|
|
126
|
-
|
|
127
|
-
expect(
|
|
128
|
-
getSubtitleRenderSpec.bind(undefined, {
|
|
129
|
-
outVideo: {
|
|
130
|
-
subtitles: { path: 'a.lrc', rawContent: 'x' }
|
|
131
|
-
}
|
|
132
|
-
} as Config)
|
|
133
|
-
).to.throw(
|
|
134
|
-
'Invalid outVideo.subtitles: specify only one of "path" or "rawContent", not both.',
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
expect(
|
|
138
|
-
getSubtitleRenderSpec.bind(undefined, {
|
|
139
|
-
outVideo: { subtitles: { alignment: 'center' as any } }
|
|
140
|
-
} as Config)
|
|
141
|
-
).to.throw('Invalid outVideo.subtitles.alignment');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('subtitleAlignmentToAss', function() {
|
|
145
|
-
expect(subtitleAlignmentToAss('bottom')).equal(2);
|
|
146
|
-
expect(subtitleAlignmentToAss('middle')).equal(10);
|
|
147
|
-
expect(subtitleAlignmentToAss('top')).equal(6);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('getFPS', function() {
|
|
151
|
-
const result1 = getFPS({
|
|
152
|
-
outVideo: {}
|
|
153
|
-
} as Config);
|
|
154
|
-
expect(result1).equal(defaults.fps);
|
|
155
|
-
|
|
156
|
-
const result2 = getFPS({
|
|
157
|
-
outVideo: { fps: 15 }
|
|
158
|
-
} as Config);
|
|
159
|
-
expect(result2).equal(15);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('checkIsPercentValue', function() {
|
|
163
|
-
const result1 = checkIsPercentValue('69%');
|
|
164
|
-
expect(result1).equal(true);
|
|
165
|
-
|
|
166
|
-
const result2 = checkIsPercentValue('69');
|
|
167
|
-
expect(result2).equal(false);
|
|
168
|
-
|
|
169
|
-
const result3 = checkIsPercentValue('fake value');
|
|
170
|
-
expect(result3).equal(false);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('getSpectrumWidthAbsolute', function() {
|
|
174
|
-
const backgroundImageWidth = 1366;
|
|
175
|
-
const result1 = getSpectrumWidthAbsolute({
|
|
176
|
-
outVideo: {}
|
|
177
|
-
} as Config, backgroundImageWidth);
|
|
178
|
-
expect(result1).equal(
|
|
179
|
-
backgroundImageWidth * (parseInt(defaults.spectrumWidth) / 100)
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
const result2 = getSpectrumWidthAbsolute({
|
|
183
|
-
outVideo: { spectrum: { width: 600 }}
|
|
184
|
-
} as Config, backgroundImageWidth);
|
|
185
|
-
expect(result2).equal(600);
|
|
186
|
-
|
|
187
|
-
const result3 = getSpectrumWidthAbsolute({
|
|
188
|
-
outVideo: { spectrum: { width: '69%' }}
|
|
189
|
-
} as Config, backgroundImageWidth);
|
|
190
|
-
expect(result3).equal(backgroundImageWidth * 0.69);
|
|
191
|
-
|
|
192
|
-
const result4 = getSpectrumWidthAbsolute.bind(
|
|
193
|
-
undefined,
|
|
194
|
-
{
|
|
195
|
-
outVideo: { spectrum: { width: '69' }}
|
|
196
|
-
} as Config,
|
|
197
|
-
backgroundImageWidth
|
|
198
|
-
);
|
|
199
|
-
expect(result4).to.throw('Invalid spectrum width value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
200
|
-
|
|
201
|
-
const result5 = getSpectrumWidthAbsolute.bind(
|
|
202
|
-
undefined,
|
|
203
|
-
{
|
|
204
|
-
outVideo: { spectrum: { width: 1 }}
|
|
205
|
-
} as Config,
|
|
206
|
-
backgroundImageWidth
|
|
207
|
-
);
|
|
208
|
-
expect(result5).to.throw('Spectrum width \'1\' is too small.');
|
|
209
|
-
|
|
210
|
-
const result6 = getSpectrumWidthAbsolute.bind(
|
|
211
|
-
undefined,
|
|
212
|
-
{
|
|
213
|
-
outVideo: { spectrum: { width: '1%' }}
|
|
214
|
-
} as Config,
|
|
215
|
-
backgroundImageWidth
|
|
216
|
-
);
|
|
217
|
-
expect(result6).to.throw('Spectrum width \'1%\' is too small.');
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('getSpectrumHeightAbsolute', function() {
|
|
221
|
-
const backgroundImageHeight = 720;
|
|
222
|
-
const result1 = getSpectrumHeightAbsolute({
|
|
223
|
-
outVideo: {}
|
|
224
|
-
} as Config, backgroundImageHeight);
|
|
225
|
-
expect(result1).equal(160);
|
|
226
|
-
|
|
227
|
-
const result2 = getSpectrumHeightAbsolute({
|
|
228
|
-
outVideo: { spectrum: { height: 420 }}
|
|
229
|
-
} as Config, backgroundImageHeight);
|
|
230
|
-
expect(result2).equal(420);
|
|
231
|
-
|
|
232
|
-
const result3 = getSpectrumHeightAbsolute({
|
|
233
|
-
outVideo: { spectrum: { height: '69%' }}
|
|
234
|
-
} as Config, backgroundImageHeight);
|
|
235
|
-
expect(result3).equal(backgroundImageHeight * 0.69);
|
|
236
|
-
|
|
237
|
-
const result4 = getSpectrumHeightAbsolute.bind(
|
|
238
|
-
undefined,
|
|
239
|
-
{
|
|
240
|
-
outVideo: { spectrum: { height: '69' }}
|
|
241
|
-
} as Config,
|
|
242
|
-
backgroundImageHeight
|
|
243
|
-
);
|
|
244
|
-
expect(result4).to.throw('Invalid spectrum height value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('getSpectrumXAbsolute', function() {
|
|
248
|
-
const spectrumWidth = 420;
|
|
249
|
-
const backgroundImageWidth = 1366;
|
|
250
|
-
const result1 = getSpectrumXAbsolute(
|
|
251
|
-
{
|
|
252
|
-
outVideo: {},
|
|
253
|
-
} as Config,
|
|
254
|
-
spectrumWidth,
|
|
255
|
-
backgroundImageWidth
|
|
256
|
-
);
|
|
257
|
-
expect(result1).equal(
|
|
258
|
-
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
const result2 = getSpectrumXAbsolute(
|
|
262
|
-
{
|
|
263
|
-
outVideo: { spectrum: { x: 420 } }
|
|
264
|
-
} as Config,
|
|
265
|
-
spectrumWidth,
|
|
266
|
-
backgroundImageWidth
|
|
267
|
-
);
|
|
268
|
-
expect(result2).equal(420);
|
|
269
|
-
|
|
270
|
-
const result3 = getSpectrumXAbsolute(
|
|
271
|
-
{
|
|
272
|
-
outVideo: { spectrum: { x: 'left' } }
|
|
273
|
-
} as Config,
|
|
274
|
-
spectrumWidth,
|
|
275
|
-
backgroundImageWidth
|
|
276
|
-
);
|
|
277
|
-
expect(result3).equal(0);
|
|
278
|
-
|
|
279
|
-
const result4 = getSpectrumXAbsolute(
|
|
280
|
-
{
|
|
281
|
-
outVideo: { spectrum: { x: 'center' } }
|
|
282
|
-
} as Config,
|
|
283
|
-
spectrumWidth,
|
|
284
|
-
backgroundImageWidth
|
|
285
|
-
);
|
|
286
|
-
expect(result4).equal(
|
|
287
|
-
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
const result5 = getSpectrumXAbsolute(
|
|
291
|
-
{
|
|
292
|
-
outVideo: { spectrum: { x: 'right' } }
|
|
293
|
-
} as Config,
|
|
294
|
-
spectrumWidth,
|
|
295
|
-
backgroundImageWidth
|
|
296
|
-
);
|
|
297
|
-
expect(result5).equal(
|
|
298
|
-
1 * backgroundImageWidth - spectrumWidth
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
const result6 = getSpectrumXAbsolute.bind(
|
|
302
|
-
undefined,
|
|
303
|
-
{
|
|
304
|
-
outVideo: { spectrum: { x: 'sagewklkg' } }
|
|
305
|
-
} as unknown as Config,
|
|
306
|
-
spectrumWidth,
|
|
307
|
-
backgroundImageWidth
|
|
308
|
-
);
|
|
309
|
-
expect(result6).to.throw('Invalid spectrum x value: sagewklkg. Valid values: left, center, right, top, middle, bottom.');
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it('getSpectrumYAbsolute', function() {
|
|
313
|
-
const spectrumHeight = 125;
|
|
314
|
-
const backgroundImageHeight = 721;
|
|
315
|
-
const result1 = getSpectrumYAbsolute(
|
|
316
|
-
{
|
|
317
|
-
outVideo: {},
|
|
318
|
-
} as Config,
|
|
319
|
-
spectrumHeight,
|
|
320
|
-
backgroundImageHeight
|
|
321
|
-
);
|
|
322
|
-
expect(result1).equal(
|
|
323
|
-
298
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
const result2 = getSpectrumYAbsolute(
|
|
327
|
-
{
|
|
328
|
-
outVideo: { spectrum: { y: 69 } }
|
|
329
|
-
} as Config,
|
|
330
|
-
spectrumHeight,
|
|
331
|
-
backgroundImageHeight
|
|
332
|
-
);
|
|
333
|
-
expect(result2).equal(69);
|
|
334
|
-
|
|
335
|
-
const result3 = getSpectrumYAbsolute(
|
|
336
|
-
{
|
|
337
|
-
outVideo: { spectrum: { y: 'top' } }
|
|
338
|
-
} as Config,
|
|
339
|
-
spectrumHeight,
|
|
340
|
-
backgroundImageHeight
|
|
341
|
-
);
|
|
342
|
-
expect(result3).equal(0);
|
|
343
|
-
|
|
344
|
-
const result4 = getSpectrumYAbsolute(
|
|
345
|
-
{
|
|
346
|
-
outVideo: { spectrum: { y: 'middle' } }
|
|
347
|
-
} as Config,
|
|
348
|
-
spectrumHeight,
|
|
349
|
-
backgroundImageHeight
|
|
350
|
-
);
|
|
351
|
-
expect(result4).equal(
|
|
352
|
-
0.5 * backgroundImageHeight - spectrumHeight / 2
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
const result5 = getSpectrumYAbsolute(
|
|
356
|
-
{
|
|
357
|
-
outVideo: { spectrum: { y: 'bottom' } }
|
|
358
|
-
} as Config,
|
|
359
|
-
spectrumHeight,
|
|
360
|
-
backgroundImageHeight
|
|
361
|
-
);
|
|
362
|
-
expect(result5).equal(
|
|
363
|
-
1 * backgroundImageHeight - spectrumHeight
|
|
364
|
-
);
|
|
365
|
-
|
|
366
|
-
const result6 = getSpectrumYAbsolute.bind(
|
|
367
|
-
undefined,
|
|
368
|
-
{
|
|
369
|
-
outVideo: { spectrum: { y: 'asokosckm' } }
|
|
370
|
-
} as unknown as Config,
|
|
371
|
-
spectrumHeight,
|
|
372
|
-
backgroundImageHeight
|
|
373
|
-
);
|
|
374
|
-
expect(result6).to.throw('Invalid spectrum y value: asokosckm. Valid values: left, center, right, top, middle, bottom.');
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it('getSpectrumColor', function() {
|
|
378
|
-
const result1 = getSpectrumColor({
|
|
379
|
-
outVideo: {}
|
|
380
|
-
} as Config);
|
|
381
|
-
expect(result1).equal(undefined);
|
|
382
|
-
|
|
383
|
-
const result2 = getSpectrumColor({
|
|
384
|
-
outVideo: { spectrum: { color: '#cccc99' } }
|
|
385
|
-
} as Config);
|
|
386
|
-
expect(result2).equal('#cccc99');
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
it('getSpectrumOpacity', function() {
|
|
390
|
-
const result1 = getSpectrumOpacity({
|
|
391
|
-
outVideo: {}
|
|
392
|
-
} as Config);
|
|
393
|
-
expect(result1).equal(defaults.spectrumOpacity);
|
|
394
|
-
|
|
395
|
-
const result2 = getSpectrumOpacity({
|
|
396
|
-
outVideo: { spectrum: { opacity: '69%' } }
|
|
397
|
-
} as Config);
|
|
398
|
-
expect(result2).equal('69%');
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('getSpectrumOpacityParsed', function() {
|
|
402
|
-
const result1 = getSpectrumOpacityParsed({
|
|
403
|
-
outVideo: {}
|
|
404
|
-
} as Config);
|
|
405
|
-
expect(result1).equal(parseInt(defaults.spectrumOpacity) / 100);
|
|
406
|
-
|
|
407
|
-
const result2 = getSpectrumOpacityParsed({
|
|
408
|
-
outVideo: { spectrum: { opacity: '69%' } }
|
|
409
|
-
} as Config);
|
|
410
|
-
expect(result2).equal(0.69);
|
|
411
|
-
|
|
412
|
-
const result3 = getSpectrumOpacityParsed.bind(
|
|
413
|
-
undefined,
|
|
414
|
-
{
|
|
415
|
-
outVideo: { spectrum: { opacity: 'fake value' } }
|
|
416
|
-
} as Config
|
|
417
|
-
);
|
|
418
|
-
expect(result3).to.throw('Invalid spectrum opacity value: \'fake value\'. Use string percent value, for example \'80%\'.');
|
|
419
|
-
|
|
420
|
-
const result4 = getSpectrumOpacityParsed.bind(
|
|
421
|
-
undefined,
|
|
422
|
-
{
|
|
423
|
-
outVideo: { spectrum: { opacity: '103%' } }
|
|
424
|
-
} as Config
|
|
425
|
-
);
|
|
426
|
-
expect(result4).to.throw('Invalid spectrum opacity value: \'103%\'. Percent values must be in range from \'0%\' to \'100%\'.');
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
it('getFfmpeg_cfr', function() {
|
|
430
|
-
const result1 = getFfmpeg_cfr({
|
|
431
|
-
tweaks: {}
|
|
432
|
-
} as Config);
|
|
433
|
-
expect(result1).equal(undefined);
|
|
434
|
-
|
|
435
|
-
const result2 = getFfmpeg_cfr({
|
|
436
|
-
tweaks: { ffmpeg_cfr: '69' }
|
|
437
|
-
} as Config);
|
|
438
|
-
expect(result2).equal('69');
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
it('getFfmpeg_preset', function() {
|
|
442
|
-
const result1 = getFfmpeg_preset({
|
|
443
|
-
tweaks: {}
|
|
444
|
-
} as Config);
|
|
445
|
-
expect(result1).equal(undefined);
|
|
446
|
-
|
|
447
|
-
const result2 = getFfmpeg_preset({
|
|
448
|
-
tweaks: { ffmpeg_preset: 'quality' }
|
|
449
|
-
} as Config);
|
|
450
|
-
expect(result2).equal('quality');
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it('getFrame_processing_delay', function() {
|
|
454
|
-
const result1 = getFrame_processing_delay({
|
|
455
|
-
tweaks: {}
|
|
456
|
-
} as Config);
|
|
457
|
-
expect(result1).equal(undefined);
|
|
458
|
-
|
|
459
|
-
const result2 = getFrame_processing_delay({
|
|
460
|
-
tweaks: { frame_processing_delay: 420 }
|
|
461
|
-
} as Config);
|
|
462
|
-
expect(result2).equal(420);
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
it('checkIsValidRotationAlias', function() {
|
|
466
|
-
const result1 = checkIsValidRotationAlias('up');
|
|
467
|
-
expect(result1).equal(true);
|
|
468
|
-
|
|
469
|
-
const result2 = checkIsValidRotationAlias('down');
|
|
470
|
-
expect(result2).equal(true);
|
|
471
|
-
|
|
472
|
-
const result3 = checkIsValidRotationAlias('fake value');
|
|
473
|
-
expect(result3).equal(false);
|
|
474
|
-
});
|
|
475
|
-
});
|
|
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
|
+
getSubtitleRenderSpec,
|
|
12
|
+
subtitleAlignmentToAss,
|
|
13
|
+
getFPS,
|
|
14
|
+
getSpectrumWidthAbsolute,
|
|
15
|
+
getSpectrumHeightAbsolute,
|
|
16
|
+
getSpectrumXAbsolute,
|
|
17
|
+
getSpectrumYAbsolute,
|
|
18
|
+
getSpectrumColor,
|
|
19
|
+
getSpectrumOpacity,
|
|
20
|
+
getSpectrumOpacityParsed,
|
|
21
|
+
getFfmpeg_cfr,
|
|
22
|
+
getFfmpeg_preset,
|
|
23
|
+
getFrame_processing_delay,
|
|
24
|
+
checkIsValidRotationAlias,
|
|
25
|
+
checkIsPercentValue
|
|
26
|
+
} from '../config';
|
|
27
|
+
|
|
28
|
+
describe('config', function() {
|
|
29
|
+
it('getAudioFilePath', function() {
|
|
30
|
+
const result = getAudioFilePath({
|
|
31
|
+
audio: { path: 'test/path' }
|
|
32
|
+
} as Config);
|
|
33
|
+
const expected = path.resolve('test/path');
|
|
34
|
+
expect(result).equal(expected);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('getAudioAutoHighlight', function() {
|
|
38
|
+
expect(
|
|
39
|
+
getAudioAutoHighlight({ audio: { path: 'a.wav' } } as Config)
|
|
40
|
+
).equal(false);
|
|
41
|
+
expect(
|
|
42
|
+
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: false } } as Config)
|
|
43
|
+
).equal(false);
|
|
44
|
+
expect(
|
|
45
|
+
getAudioAutoHighlight({ audio: { path: 'a.wav', autoHighlight: true } } as Config)
|
|
46
|
+
).equal(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('getAudioAutoHighlightCount', function() {
|
|
50
|
+
expect(
|
|
51
|
+
getAudioAutoHighlightCount({ audio: { path: 'a.wav' } } as Config)
|
|
52
|
+
).equal(1);
|
|
53
|
+
expect(
|
|
54
|
+
getAudioAutoHighlightCount({ audio: { path: 'a.wav', autoHighlightCount: 3 } } as Config)
|
|
55
|
+
).equal(3);
|
|
56
|
+
expect(
|
|
57
|
+
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 0 } } as Config)
|
|
58
|
+
).to.throw('Invalid audio.autoHighlightCount');
|
|
59
|
+
expect(
|
|
60
|
+
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: 1.5 } } as Config)
|
|
61
|
+
).to.throw('Invalid audio.autoHighlightCount');
|
|
62
|
+
expect(
|
|
63
|
+
getAudioAutoHighlightCount.bind(undefined, { audio: { path: 'a.wav', autoHighlightCount: NaN } } as Config)
|
|
64
|
+
).to.throw('Invalid audio.autoHighlightCount');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('getBackgroundImagePath', function() {
|
|
68
|
+
const result = getBackgroundImagePath({
|
|
69
|
+
image: { path: 'test/path' }
|
|
70
|
+
} as Config);
|
|
71
|
+
const expected = path.resolve('test/path');
|
|
72
|
+
expect(result).equal(expected);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('getOutVideoPath', function() {
|
|
76
|
+
const result = getOutVideoPath({
|
|
77
|
+
outVideo: { path: 'test/path' }
|
|
78
|
+
} as Config);
|
|
79
|
+
const expected = path.resolve('test/path');
|
|
80
|
+
expect(result).equal(expected);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('getSubtitleRenderSpec', function() {
|
|
84
|
+
expect(
|
|
85
|
+
getSubtitleRenderSpec({ outVideo: {} } as Config)
|
|
86
|
+
).equal(undefined);
|
|
87
|
+
|
|
88
|
+
expect(
|
|
89
|
+
getSubtitleRenderSpec({
|
|
90
|
+
outVideo: { subtitles: '1\n00:00:00,000 --> 00:00:01,000\nTest' }
|
|
91
|
+
} as Config)
|
|
92
|
+
).deep.equal({
|
|
93
|
+
source: { kind: 'inline', text: '1\n00:00:00,000 --> 00:00:01,000\nTest' },
|
|
94
|
+
alignment: 'bottom',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
expect(
|
|
98
|
+
getSubtitleRenderSpec({
|
|
99
|
+
outVideo: {
|
|
100
|
+
subtitles: { rawContent: '1\n00:00:00,000 --> 00:00:01,000\nHi', alignment: 'top' }
|
|
101
|
+
}
|
|
102
|
+
} as Config)
|
|
103
|
+
).deep.equal({
|
|
104
|
+
source: { kind: 'inline', text: '1\n00:00:00,000 --> 00:00:01,000\nHi' },
|
|
105
|
+
alignment: 'top',
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(
|
|
109
|
+
getSubtitleRenderSpec({
|
|
110
|
+
outVideo: { subtitles: { path: 'media/sub.srt' } }
|
|
111
|
+
} as Config)
|
|
112
|
+
).deep.equal({
|
|
113
|
+
source: { kind: 'file', path: path.resolve('media/sub.srt') },
|
|
114
|
+
alignment: 'bottom',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(
|
|
118
|
+
getSubtitleRenderSpec({ outVideo: { subtitles: {} } } as Config)
|
|
119
|
+
).equal(undefined);
|
|
120
|
+
|
|
121
|
+
expect(
|
|
122
|
+
getSubtitleRenderSpec.bind(undefined, {
|
|
123
|
+
outVideo: { subtitles: '' }
|
|
124
|
+
} as unknown as Config)
|
|
125
|
+
).to.throw('Invalid outVideo.subtitles: expected non-empty string content');
|
|
126
|
+
|
|
127
|
+
expect(
|
|
128
|
+
getSubtitleRenderSpec.bind(undefined, {
|
|
129
|
+
outVideo: {
|
|
130
|
+
subtitles: { path: 'a.lrc', rawContent: 'x' }
|
|
131
|
+
}
|
|
132
|
+
} as Config)
|
|
133
|
+
).to.throw(
|
|
134
|
+
'Invalid outVideo.subtitles: specify only one of "path" or "rawContent", not both.',
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
expect(
|
|
138
|
+
getSubtitleRenderSpec.bind(undefined, {
|
|
139
|
+
outVideo: { subtitles: { alignment: 'center' as any } }
|
|
140
|
+
} as Config)
|
|
141
|
+
).to.throw('Invalid outVideo.subtitles.alignment');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('subtitleAlignmentToAss', function() {
|
|
145
|
+
expect(subtitleAlignmentToAss('bottom')).equal(2);
|
|
146
|
+
expect(subtitleAlignmentToAss('middle')).equal(10);
|
|
147
|
+
expect(subtitleAlignmentToAss('top')).equal(6);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('getFPS', function() {
|
|
151
|
+
const result1 = getFPS({
|
|
152
|
+
outVideo: {}
|
|
153
|
+
} as Config);
|
|
154
|
+
expect(result1).equal(defaults.fps);
|
|
155
|
+
|
|
156
|
+
const result2 = getFPS({
|
|
157
|
+
outVideo: { fps: 15 }
|
|
158
|
+
} as Config);
|
|
159
|
+
expect(result2).equal(15);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('checkIsPercentValue', function() {
|
|
163
|
+
const result1 = checkIsPercentValue('69%');
|
|
164
|
+
expect(result1).equal(true);
|
|
165
|
+
|
|
166
|
+
const result2 = checkIsPercentValue('69');
|
|
167
|
+
expect(result2).equal(false);
|
|
168
|
+
|
|
169
|
+
const result3 = checkIsPercentValue('fake value');
|
|
170
|
+
expect(result3).equal(false);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('getSpectrumWidthAbsolute', function() {
|
|
174
|
+
const backgroundImageWidth = 1366;
|
|
175
|
+
const result1 = getSpectrumWidthAbsolute({
|
|
176
|
+
outVideo: {}
|
|
177
|
+
} as Config, backgroundImageWidth);
|
|
178
|
+
expect(result1).equal(
|
|
179
|
+
backgroundImageWidth * (parseInt(defaults.spectrumWidth) / 100)
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const result2 = getSpectrumWidthAbsolute({
|
|
183
|
+
outVideo: { spectrum: { width: 600 }}
|
|
184
|
+
} as Config, backgroundImageWidth);
|
|
185
|
+
expect(result2).equal(600);
|
|
186
|
+
|
|
187
|
+
const result3 = getSpectrumWidthAbsolute({
|
|
188
|
+
outVideo: { spectrum: { width: '69%' }}
|
|
189
|
+
} as Config, backgroundImageWidth);
|
|
190
|
+
expect(result3).equal(backgroundImageWidth * 0.69);
|
|
191
|
+
|
|
192
|
+
const result4 = getSpectrumWidthAbsolute.bind(
|
|
193
|
+
undefined,
|
|
194
|
+
{
|
|
195
|
+
outVideo: { spectrum: { width: '69' }}
|
|
196
|
+
} as Config,
|
|
197
|
+
backgroundImageWidth
|
|
198
|
+
);
|
|
199
|
+
expect(result4).to.throw('Invalid spectrum width value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
200
|
+
|
|
201
|
+
const result5 = getSpectrumWidthAbsolute.bind(
|
|
202
|
+
undefined,
|
|
203
|
+
{
|
|
204
|
+
outVideo: { spectrum: { width: 1 }}
|
|
205
|
+
} as Config,
|
|
206
|
+
backgroundImageWidth
|
|
207
|
+
);
|
|
208
|
+
expect(result5).to.throw('Spectrum width \'1\' is too small.');
|
|
209
|
+
|
|
210
|
+
const result6 = getSpectrumWidthAbsolute.bind(
|
|
211
|
+
undefined,
|
|
212
|
+
{
|
|
213
|
+
outVideo: { spectrum: { width: '1%' }}
|
|
214
|
+
} as Config,
|
|
215
|
+
backgroundImageWidth
|
|
216
|
+
);
|
|
217
|
+
expect(result6).to.throw('Spectrum width \'1%\' is too small.');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('getSpectrumHeightAbsolute', function() {
|
|
221
|
+
const backgroundImageHeight = 720;
|
|
222
|
+
const result1 = getSpectrumHeightAbsolute({
|
|
223
|
+
outVideo: {}
|
|
224
|
+
} as Config, backgroundImageHeight);
|
|
225
|
+
expect(result1).equal(160);
|
|
226
|
+
|
|
227
|
+
const result2 = getSpectrumHeightAbsolute({
|
|
228
|
+
outVideo: { spectrum: { height: 420 }}
|
|
229
|
+
} as Config, backgroundImageHeight);
|
|
230
|
+
expect(result2).equal(420);
|
|
231
|
+
|
|
232
|
+
const result3 = getSpectrumHeightAbsolute({
|
|
233
|
+
outVideo: { spectrum: { height: '69%' }}
|
|
234
|
+
} as Config, backgroundImageHeight);
|
|
235
|
+
expect(result3).equal(backgroundImageHeight * 0.69);
|
|
236
|
+
|
|
237
|
+
const result4 = getSpectrumHeightAbsolute.bind(
|
|
238
|
+
undefined,
|
|
239
|
+
{
|
|
240
|
+
outVideo: { spectrum: { height: '69' }}
|
|
241
|
+
} as Config,
|
|
242
|
+
backgroundImageHeight
|
|
243
|
+
);
|
|
244
|
+
expect(result4).to.throw('Invalid spectrum height value: \'69\'. Use number value or percent value in string, for example: \'30%\'.');
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('getSpectrumXAbsolute', function() {
|
|
248
|
+
const spectrumWidth = 420;
|
|
249
|
+
const backgroundImageWidth = 1366;
|
|
250
|
+
const result1 = getSpectrumXAbsolute(
|
|
251
|
+
{
|
|
252
|
+
outVideo: {},
|
|
253
|
+
} as Config,
|
|
254
|
+
spectrumWidth,
|
|
255
|
+
backgroundImageWidth
|
|
256
|
+
);
|
|
257
|
+
expect(result1).equal(
|
|
258
|
+
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const result2 = getSpectrumXAbsolute(
|
|
262
|
+
{
|
|
263
|
+
outVideo: { spectrum: { x: 420 } }
|
|
264
|
+
} as Config,
|
|
265
|
+
spectrumWidth,
|
|
266
|
+
backgroundImageWidth
|
|
267
|
+
);
|
|
268
|
+
expect(result2).equal(420);
|
|
269
|
+
|
|
270
|
+
const result3 = getSpectrumXAbsolute(
|
|
271
|
+
{
|
|
272
|
+
outVideo: { spectrum: { x: 'left' } }
|
|
273
|
+
} as Config,
|
|
274
|
+
spectrumWidth,
|
|
275
|
+
backgroundImageWidth
|
|
276
|
+
);
|
|
277
|
+
expect(result3).equal(0);
|
|
278
|
+
|
|
279
|
+
const result4 = getSpectrumXAbsolute(
|
|
280
|
+
{
|
|
281
|
+
outVideo: { spectrum: { x: 'center' } }
|
|
282
|
+
} as Config,
|
|
283
|
+
spectrumWidth,
|
|
284
|
+
backgroundImageWidth
|
|
285
|
+
);
|
|
286
|
+
expect(result4).equal(
|
|
287
|
+
0.5 * backgroundImageWidth - spectrumWidth / 2
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const result5 = getSpectrumXAbsolute(
|
|
291
|
+
{
|
|
292
|
+
outVideo: { spectrum: { x: 'right' } }
|
|
293
|
+
} as Config,
|
|
294
|
+
spectrumWidth,
|
|
295
|
+
backgroundImageWidth
|
|
296
|
+
);
|
|
297
|
+
expect(result5).equal(
|
|
298
|
+
1 * backgroundImageWidth - spectrumWidth
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const result6 = getSpectrumXAbsolute.bind(
|
|
302
|
+
undefined,
|
|
303
|
+
{
|
|
304
|
+
outVideo: { spectrum: { x: 'sagewklkg' } }
|
|
305
|
+
} as unknown as Config,
|
|
306
|
+
spectrumWidth,
|
|
307
|
+
backgroundImageWidth
|
|
308
|
+
);
|
|
309
|
+
expect(result6).to.throw('Invalid spectrum x value: sagewklkg. Valid values: left, center, right, top, middle, bottom.');
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('getSpectrumYAbsolute', function() {
|
|
313
|
+
const spectrumHeight = 125;
|
|
314
|
+
const backgroundImageHeight = 721;
|
|
315
|
+
const result1 = getSpectrumYAbsolute(
|
|
316
|
+
{
|
|
317
|
+
outVideo: {},
|
|
318
|
+
} as Config,
|
|
319
|
+
spectrumHeight,
|
|
320
|
+
backgroundImageHeight
|
|
321
|
+
);
|
|
322
|
+
expect(result1).equal(
|
|
323
|
+
298
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
const result2 = getSpectrumYAbsolute(
|
|
327
|
+
{
|
|
328
|
+
outVideo: { spectrum: { y: 69 } }
|
|
329
|
+
} as Config,
|
|
330
|
+
spectrumHeight,
|
|
331
|
+
backgroundImageHeight
|
|
332
|
+
);
|
|
333
|
+
expect(result2).equal(69);
|
|
334
|
+
|
|
335
|
+
const result3 = getSpectrumYAbsolute(
|
|
336
|
+
{
|
|
337
|
+
outVideo: { spectrum: { y: 'top' } }
|
|
338
|
+
} as Config,
|
|
339
|
+
spectrumHeight,
|
|
340
|
+
backgroundImageHeight
|
|
341
|
+
);
|
|
342
|
+
expect(result3).equal(0);
|
|
343
|
+
|
|
344
|
+
const result4 = getSpectrumYAbsolute(
|
|
345
|
+
{
|
|
346
|
+
outVideo: { spectrum: { y: 'middle' } }
|
|
347
|
+
} as Config,
|
|
348
|
+
spectrumHeight,
|
|
349
|
+
backgroundImageHeight
|
|
350
|
+
);
|
|
351
|
+
expect(result4).equal(
|
|
352
|
+
0.5 * backgroundImageHeight - spectrumHeight / 2
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
const result5 = getSpectrumYAbsolute(
|
|
356
|
+
{
|
|
357
|
+
outVideo: { spectrum: { y: 'bottom' } }
|
|
358
|
+
} as Config,
|
|
359
|
+
spectrumHeight,
|
|
360
|
+
backgroundImageHeight
|
|
361
|
+
);
|
|
362
|
+
expect(result5).equal(
|
|
363
|
+
1 * backgroundImageHeight - spectrumHeight
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const result6 = getSpectrumYAbsolute.bind(
|
|
367
|
+
undefined,
|
|
368
|
+
{
|
|
369
|
+
outVideo: { spectrum: { y: 'asokosckm' } }
|
|
370
|
+
} as unknown as Config,
|
|
371
|
+
spectrumHeight,
|
|
372
|
+
backgroundImageHeight
|
|
373
|
+
);
|
|
374
|
+
expect(result6).to.throw('Invalid spectrum y value: asokosckm. Valid values: left, center, right, top, middle, bottom.');
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it('getSpectrumColor', function() {
|
|
378
|
+
const result1 = getSpectrumColor({
|
|
379
|
+
outVideo: {}
|
|
380
|
+
} as Config);
|
|
381
|
+
expect(result1).equal(undefined);
|
|
382
|
+
|
|
383
|
+
const result2 = getSpectrumColor({
|
|
384
|
+
outVideo: { spectrum: { color: '#cccc99' } }
|
|
385
|
+
} as Config);
|
|
386
|
+
expect(result2).equal('#cccc99');
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('getSpectrumOpacity', function() {
|
|
390
|
+
const result1 = getSpectrumOpacity({
|
|
391
|
+
outVideo: {}
|
|
392
|
+
} as Config);
|
|
393
|
+
expect(result1).equal(defaults.spectrumOpacity);
|
|
394
|
+
|
|
395
|
+
const result2 = getSpectrumOpacity({
|
|
396
|
+
outVideo: { spectrum: { opacity: '69%' } }
|
|
397
|
+
} as Config);
|
|
398
|
+
expect(result2).equal('69%');
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('getSpectrumOpacityParsed', function() {
|
|
402
|
+
const result1 = getSpectrumOpacityParsed({
|
|
403
|
+
outVideo: {}
|
|
404
|
+
} as Config);
|
|
405
|
+
expect(result1).equal(parseInt(defaults.spectrumOpacity) / 100);
|
|
406
|
+
|
|
407
|
+
const result2 = getSpectrumOpacityParsed({
|
|
408
|
+
outVideo: { spectrum: { opacity: '69%' } }
|
|
409
|
+
} as Config);
|
|
410
|
+
expect(result2).equal(0.69);
|
|
411
|
+
|
|
412
|
+
const result3 = getSpectrumOpacityParsed.bind(
|
|
413
|
+
undefined,
|
|
414
|
+
{
|
|
415
|
+
outVideo: { spectrum: { opacity: 'fake value' } }
|
|
416
|
+
} as Config
|
|
417
|
+
);
|
|
418
|
+
expect(result3).to.throw('Invalid spectrum opacity value: \'fake value\'. Use string percent value, for example \'80%\'.');
|
|
419
|
+
|
|
420
|
+
const result4 = getSpectrumOpacityParsed.bind(
|
|
421
|
+
undefined,
|
|
422
|
+
{
|
|
423
|
+
outVideo: { spectrum: { opacity: '103%' } }
|
|
424
|
+
} as Config
|
|
425
|
+
);
|
|
426
|
+
expect(result4).to.throw('Invalid spectrum opacity value: \'103%\'. Percent values must be in range from \'0%\' to \'100%\'.');
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('getFfmpeg_cfr', function() {
|
|
430
|
+
const result1 = getFfmpeg_cfr({
|
|
431
|
+
tweaks: {}
|
|
432
|
+
} as Config);
|
|
433
|
+
expect(result1).equal(undefined);
|
|
434
|
+
|
|
435
|
+
const result2 = getFfmpeg_cfr({
|
|
436
|
+
tweaks: { ffmpeg_cfr: '69' }
|
|
437
|
+
} as Config);
|
|
438
|
+
expect(result2).equal('69');
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
it('getFfmpeg_preset', function() {
|
|
442
|
+
const result1 = getFfmpeg_preset({
|
|
443
|
+
tweaks: {}
|
|
444
|
+
} as Config);
|
|
445
|
+
expect(result1).equal(undefined);
|
|
446
|
+
|
|
447
|
+
const result2 = getFfmpeg_preset({
|
|
448
|
+
tweaks: { ffmpeg_preset: 'quality' }
|
|
449
|
+
} as Config);
|
|
450
|
+
expect(result2).equal('quality');
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
it('getFrame_processing_delay', function() {
|
|
454
|
+
const result1 = getFrame_processing_delay({
|
|
455
|
+
tweaks: {}
|
|
456
|
+
} as Config);
|
|
457
|
+
expect(result1).equal(undefined);
|
|
458
|
+
|
|
459
|
+
const result2 = getFrame_processing_delay({
|
|
460
|
+
tweaks: { frame_processing_delay: 420 }
|
|
461
|
+
} as Config);
|
|
462
|
+
expect(result2).equal(420);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it('checkIsValidRotationAlias', function() {
|
|
466
|
+
const result1 = checkIsValidRotationAlias('up');
|
|
467
|
+
expect(result1).equal(true);
|
|
468
|
+
|
|
469
|
+
const result2 = checkIsValidRotationAlias('down');
|
|
470
|
+
expect(result2).equal(true);
|
|
471
|
+
|
|
472
|
+
const result3 = checkIsValidRotationAlias('fake value');
|
|
473
|
+
expect(result3).equal(false);
|
|
474
|
+
});
|
|
475
|
+
});
|