nodejs-audio-visualizer 4.2.4 → 4.2.6

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.
@@ -1,71 +1,71 @@
1
- import { expect } from 'chai';
2
- import { Writable, Readable, Pipe } from 'stream';
3
- import { spawnFfmpegVideoWriter } from '../video';
4
- import { createSandbox, SinonStub } from 'sinon';
5
- import child_process, { ChildProcessWithoutNullStreams } from 'child_process';
6
-
7
- let childProcessStream = {
8
- stdin: new Writable(),
9
- stderr: new Readable(),
10
- };
11
-
12
- const videoSandbox = createSandbox();
13
-
14
- describe('video', function () {
15
-
16
- this.beforeAll(function () {
17
- videoSandbox.stub(child_process, 'spawn').returns(childProcessStream as ChildProcessWithoutNullStreams);
18
- });
19
-
20
- this.afterAll(function () {
21
- videoSandbox.restore();
22
- });
23
-
24
- it('spawnFfmpegVideoWriter returns truthy value', function () {
25
- const childProcessReadableStream = new Readable();
26
- childProcessReadableStream._read = () => { };
27
- const childProcessWritableStream = new Writable();
28
- (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
29
-
30
- childProcessStream.stdin = childProcessWritableStream;
31
- childProcessStream.stderr = childProcessReadableStream;
32
-
33
- const result = spawnFfmpegVideoWriter({ audioFilename: 'test', videoFileName: 'test', fps: 11 });
34
- expect(!!result).equal(true);
35
- });
36
-
37
- it('spawnFfmpegVideoWriter uses -ss and -t for single audioSegment', function () {
38
- const childProcessReadableStream = new Readable();
39
- childProcessReadableStream._read = () => { };
40
- const childProcessWritableStream = new Writable();
41
- (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
42
-
43
- childProcessStream.stdin = childProcessWritableStream;
44
- childProcessStream.stderr = childProcessReadableStream;
45
-
46
- let spawnArgs: string[] = [];
47
- const spawnStub = child_process.spawn as SinonStub;
48
- spawnStub.callsFake((_cmd: string, args: string[]) => {
49
- spawnArgs = args;
50
- return childProcessStream as ChildProcessWithoutNullStreams;
51
- });
52
-
53
- spawnFfmpegVideoWriter({
54
- audioFilename: 'audio.mp3',
55
- videoFileName: 'out.mp4',
56
- fps: 25,
57
- audioSegment: { seekSeconds: 12, durationSeconds: 15 },
58
- });
59
-
60
- spawnStub.resetBehavior();
61
- spawnStub.returns(childProcessStream as ChildProcessWithoutNullStreams);
62
-
63
- expect(spawnArgs).to.not.include('-filter_complex');
64
- const ssIdx = spawnArgs.indexOf('-ss');
65
- expect(ssIdx).greaterThan(-1);
66
- expect(spawnArgs[ssIdx + 1]).to.equal('12');
67
- const tIdx = spawnArgs.indexOf('-t');
68
- expect(tIdx).greaterThan(-1);
69
- expect(spawnArgs[tIdx + 1]).to.equal('15');
70
- });
71
- });
1
+ import { expect } from 'chai';
2
+ import { Writable, Readable, Pipe } from 'stream';
3
+ import { spawnFfmpegVideoWriter } from '../video';
4
+ import { createSandbox, SinonStub } from 'sinon';
5
+ import child_process, { ChildProcessWithoutNullStreams } from 'child_process';
6
+
7
+ let childProcessStream = {
8
+ stdin: new Writable(),
9
+ stderr: new Readable(),
10
+ };
11
+
12
+ const videoSandbox = createSandbox();
13
+
14
+ describe('video', function () {
15
+
16
+ this.beforeAll(function () {
17
+ videoSandbox.stub(child_process, 'spawn').returns(childProcessStream as ChildProcessWithoutNullStreams);
18
+ });
19
+
20
+ this.afterAll(function () {
21
+ videoSandbox.restore();
22
+ });
23
+
24
+ it('spawnFfmpegVideoWriter returns truthy value', function () {
25
+ const childProcessReadableStream = new Readable();
26
+ childProcessReadableStream._read = () => { };
27
+ const childProcessWritableStream = new Writable();
28
+ (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
29
+
30
+ childProcessStream.stdin = childProcessWritableStream;
31
+ childProcessStream.stderr = childProcessReadableStream;
32
+
33
+ const result = spawnFfmpegVideoWriter({ audioFilename: 'test', videoFileName: 'test', fps: 11 });
34
+ expect(!!result).equal(true);
35
+ });
36
+
37
+ it('spawnFfmpegVideoWriter uses -ss and -t for single audioSegment', function () {
38
+ const childProcessReadableStream = new Readable();
39
+ childProcessReadableStream._read = () => { };
40
+ const childProcessWritableStream = new Writable();
41
+ (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
42
+
43
+ childProcessStream.stdin = childProcessWritableStream;
44
+ childProcessStream.stderr = childProcessReadableStream;
45
+
46
+ let spawnArgs: string[] = [];
47
+ const spawnStub = child_process.spawn as SinonStub;
48
+ spawnStub.callsFake((_cmd: string, args: string[]) => {
49
+ spawnArgs = args;
50
+ return childProcessStream as ChildProcessWithoutNullStreams;
51
+ });
52
+
53
+ spawnFfmpegVideoWriter({
54
+ audioFilename: 'audio.mp3',
55
+ videoFileName: 'out.mp4',
56
+ fps: 25,
57
+ audioSegment: { seekSeconds: 12, durationSeconds: 15 },
58
+ });
59
+
60
+ spawnStub.resetBehavior();
61
+ spawnStub.returns(childProcessStream as ChildProcessWithoutNullStreams);
62
+
63
+ expect(spawnArgs).to.not.include('-filter_complex');
64
+ const ssIdx = spawnArgs.indexOf('-ss');
65
+ expect(ssIdx).greaterThan(-1);
66
+ expect(spawnArgs[ssIdx + 1]).to.equal('12');
67
+ const tIdx = spawnArgs.indexOf('-t');
68
+ expect(tIdx).greaterThan(-1);
69
+ expect(spawnArgs[tIdx + 1]).to.equal('15');
70
+ });
71
+ });
package/src/typings.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- declare module 'fft-js' {
2
- export function fft(signal: number[]): [number, number][];
3
- export const util: {
4
- fftFreq(phasors: [number, number][], sampleRate: number): number[];
5
- fftMag(phasors: [number, number][]): number[];
6
- };
1
+ declare module 'fft-js' {
2
+ export function fft(signal: number[]): [number, number][];
3
+ export const util: {
4
+ fftFreq(phasors: [number, number][], sampleRate: number): number[];
5
+ fftMag(phasors: [number, number][]): number[];
6
+ };
7
7
  }