nodejs-audio-visualizer 4.3.6 → 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.
Files changed (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +75 -75
  3. package/dist/audio.d.ts +12 -12
  4. package/dist/audio.js +120 -120
  5. package/dist/beats.d.ts +19 -19
  6. package/dist/beats.js +43 -43
  7. package/dist/bpmEncoder.d.ts +14 -14
  8. package/dist/bpmEncoder.js +97 -97
  9. package/dist/config.d.ts +67 -67
  10. package/dist/config.js +356 -356
  11. package/dist/dsp.d.ts +16 -16
  12. package/dist/dsp.js +76 -76
  13. package/dist/highlight.d.ts +32 -32
  14. package/dist/highlight.js +325 -325
  15. package/dist/image.d.ts +79 -79
  16. package/dist/image.js +458 -458
  17. package/dist/index.d.ts +72 -72
  18. package/dist/index.js +536 -533
  19. package/dist/index.js.map +1 -1
  20. package/dist/subtitleConvert.d.ts +3 -3
  21. package/dist/subtitleConvert.js +61 -61
  22. package/dist/video.d.ts +72 -72
  23. package/dist/video.js +338 -338
  24. package/dist/waitForEventLoop.d.ts +1 -1
  25. package/dist/waitForEventLoop.js +5 -5
  26. package/package.json +61 -61
  27. package/src/audio.ts +120 -120
  28. package/src/beats.ts +68 -68
  29. package/src/bpmEncoder.ts +97 -97
  30. package/src/config.ts +462 -462
  31. package/src/dsp.ts +95 -95
  32. package/src/highlight.ts +284 -284
  33. package/src/image.ts +602 -602
  34. package/src/index.ts +678 -674
  35. package/src/subtitleConvert.ts +63 -63
  36. package/src/tests/audio.test.ts +96 -96
  37. package/src/tests/config.test.ts +475 -475
  38. package/src/tests/dsp.test.ts +24 -24
  39. package/src/tests/highlight.test.ts +178 -178
  40. package/src/tests/image.test.ts +222 -222
  41. package/src/tests/index.test.ts +63 -63
  42. package/src/tests/subtitleConvert.test.ts +23 -23
  43. package/src/tests/video.test.ts +138 -138
  44. package/src/typings.d.ts +6 -6
  45. package/src/video.ts +437 -437
  46. package/src/waitForEventLoop.ts +2 -2
@@ -1,138 +1,138 @@
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
-
72
- it('spawnFfmpegVideoWriter adds subtitles filter when subtitle file is provided', function () {
73
- const childProcessReadableStream = new Readable();
74
- childProcessReadableStream._read = () => { };
75
- const childProcessWritableStream = new Writable();
76
- (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
77
-
78
- childProcessStream.stdin = childProcessWritableStream;
79
- childProcessStream.stderr = childProcessReadableStream;
80
-
81
- let spawnArgs: string[] = [];
82
- const spawnStub = child_process.spawn as SinonStub;
83
- spawnStub.callsFake((_cmd: string, args: string[]) => {
84
- spawnArgs = args;
85
- return childProcessStream as ChildProcessWithoutNullStreams;
86
- });
87
-
88
- spawnFfmpegVideoWriter({
89
- audioFilename: 'audio.mp3',
90
- subtitleFilename: '/tmp/subtitles.srt',
91
- videoFileName: 'out.mp4',
92
- fps: 25,
93
- });
94
-
95
- spawnStub.resetBehavior();
96
- spawnStub.returns(childProcessStream as ChildProcessWithoutNullStreams);
97
-
98
- const vfIdx = spawnArgs.indexOf('-vf');
99
- expect(vfIdx).greaterThan(-1);
100
- expect(spawnArgs[vfIdx + 1]).to.equal(
101
- "subtitles='/tmp/subtitles.srt':force_style='Alignment=2'",
102
- );
103
- });
104
-
105
- it('spawnFfmpegVideoWriter passes subtitle Alignment from subtitleAlignmentAss', function () {
106
- const childProcessReadableStream = new Readable();
107
- childProcessReadableStream._read = () => { };
108
- const childProcessWritableStream = new Writable();
109
- (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
110
-
111
- childProcessStream.stdin = childProcessWritableStream;
112
- childProcessStream.stderr = childProcessReadableStream;
113
-
114
- let spawnArgs: string[] = [];
115
- const spawnStub = child_process.spawn as SinonStub;
116
- spawnStub.callsFake((_cmd: string, args: string[]) => {
117
- spawnArgs = args;
118
- return childProcessStream as ChildProcessWithoutNullStreams;
119
- });
120
-
121
- spawnFfmpegVideoWriter({
122
- audioFilename: 'audio.mp3',
123
- subtitleFilename: '/tmp/subtitles.srt',
124
- subtitleAlignmentAss: 8,
125
- videoFileName: 'out.mp4',
126
- fps: 25,
127
- });
128
-
129
- spawnStub.resetBehavior();
130
- spawnStub.returns(childProcessStream as ChildProcessWithoutNullStreams);
131
-
132
- const vfIdx = spawnArgs.indexOf('-vf');
133
- expect(vfIdx).greaterThan(-1);
134
- expect(spawnArgs[vfIdx + 1]).to.equal(
135
- "subtitles='/tmp/subtitles.srt':force_style='Alignment=8'",
136
- );
137
- });
138
- });
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
+
72
+ it('spawnFfmpegVideoWriter adds subtitles filter when subtitle file is provided', function () {
73
+ const childProcessReadableStream = new Readable();
74
+ childProcessReadableStream._read = () => { };
75
+ const childProcessWritableStream = new Writable();
76
+ (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
77
+
78
+ childProcessStream.stdin = childProcessWritableStream;
79
+ childProcessStream.stderr = childProcessReadableStream;
80
+
81
+ let spawnArgs: string[] = [];
82
+ const spawnStub = child_process.spawn as SinonStub;
83
+ spawnStub.callsFake((_cmd: string, args: string[]) => {
84
+ spawnArgs = args;
85
+ return childProcessStream as ChildProcessWithoutNullStreams;
86
+ });
87
+
88
+ spawnFfmpegVideoWriter({
89
+ audioFilename: 'audio.mp3',
90
+ subtitleFilename: '/tmp/subtitles.srt',
91
+ videoFileName: 'out.mp4',
92
+ fps: 25,
93
+ });
94
+
95
+ spawnStub.resetBehavior();
96
+ spawnStub.returns(childProcessStream as ChildProcessWithoutNullStreams);
97
+
98
+ const vfIdx = spawnArgs.indexOf('-vf');
99
+ expect(vfIdx).greaterThan(-1);
100
+ expect(spawnArgs[vfIdx + 1]).to.equal(
101
+ "subtitles='/tmp/subtitles.srt':force_style='Alignment=2'",
102
+ );
103
+ });
104
+
105
+ it('spawnFfmpegVideoWriter passes subtitle Alignment from subtitleAlignmentAss', function () {
106
+ const childProcessReadableStream = new Readable();
107
+ childProcessReadableStream._read = () => { };
108
+ const childProcessWritableStream = new Writable();
109
+ (<Pipe>childProcessWritableStream.pipe) = () => childProcessWritableStream;
110
+
111
+ childProcessStream.stdin = childProcessWritableStream;
112
+ childProcessStream.stderr = childProcessReadableStream;
113
+
114
+ let spawnArgs: string[] = [];
115
+ const spawnStub = child_process.spawn as SinonStub;
116
+ spawnStub.callsFake((_cmd: string, args: string[]) => {
117
+ spawnArgs = args;
118
+ return childProcessStream as ChildProcessWithoutNullStreams;
119
+ });
120
+
121
+ spawnFfmpegVideoWriter({
122
+ audioFilename: 'audio.mp3',
123
+ subtitleFilename: '/tmp/subtitles.srt',
124
+ subtitleAlignmentAss: 8,
125
+ videoFileName: 'out.mp4',
126
+ fps: 25,
127
+ });
128
+
129
+ spawnStub.resetBehavior();
130
+ spawnStub.returns(childProcessStream as ChildProcessWithoutNullStreams);
131
+
132
+ const vfIdx = spawnArgs.indexOf('-vf');
133
+ expect(vfIdx).greaterThan(-1);
134
+ expect(spawnArgs[vfIdx + 1]).to.equal(
135
+ "subtitles='/tmp/subtitles.srt':force_style='Alignment=8'",
136
+ );
137
+ });
138
+ });
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
  }