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/dist/bpmEncoder.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var writeBmpHeader = function (buffer, width, height, rgbSize) {
|
|
4
|
-
var headerInfoSize = 40;
|
|
5
|
-
var offset = 54;
|
|
6
|
-
var fileSize = rgbSize + offset;
|
|
7
|
-
var pos = 0;
|
|
8
|
-
buffer.write('BM', pos, 2);
|
|
9
|
-
pos += 2;
|
|
10
|
-
buffer.writeUInt32LE(fileSize, pos);
|
|
11
|
-
pos += 4;
|
|
12
|
-
buffer.writeUInt32LE(0, pos);
|
|
13
|
-
pos += 4;
|
|
14
|
-
buffer.writeUInt32LE(offset, pos);
|
|
15
|
-
pos += 4;
|
|
16
|
-
buffer.writeUInt32LE(headerInfoSize, pos);
|
|
17
|
-
pos += 4;
|
|
18
|
-
buffer.writeUInt32LE(width, pos);
|
|
19
|
-
pos += 4;
|
|
20
|
-
buffer.writeInt32LE(-height, pos);
|
|
21
|
-
pos += 4;
|
|
22
|
-
buffer.writeUInt16LE(1, pos);
|
|
23
|
-
pos += 2;
|
|
24
|
-
buffer.writeUInt16LE(24, pos);
|
|
25
|
-
pos += 2;
|
|
26
|
-
buffer.writeUInt32LE(0, pos);
|
|
27
|
-
pos += 4;
|
|
28
|
-
buffer.writeUInt32LE(rgbSize, pos);
|
|
29
|
-
pos += 4;
|
|
30
|
-
buffer.writeUInt32LE(0, pos);
|
|
31
|
-
pos += 4;
|
|
32
|
-
buffer.writeUInt32LE(0, pos);
|
|
33
|
-
pos += 4;
|
|
34
|
-
buffer.writeUInt32LE(0, pos);
|
|
35
|
-
pos += 4;
|
|
36
|
-
buffer.writeUInt32LE(0, pos);
|
|
37
|
-
pos += 4;
|
|
38
|
-
return offset;
|
|
39
|
-
};
|
|
40
|
-
exports.createBpmEncoder = function (imgData) {
|
|
41
|
-
var width = imgData.width;
|
|
42
|
-
var height = imgData.height;
|
|
43
|
-
var extraBytes = width % 4;
|
|
44
|
-
var rgbSize = height * (3 * width + extraBytes);
|
|
45
|
-
var offset = 54;
|
|
46
|
-
return function (buffer) {
|
|
47
|
-
var tempBuffer = Buffer.alloc(offset + rgbSize);
|
|
48
|
-
var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
|
|
49
|
-
var i = 0;
|
|
50
|
-
var rowBytes = 3 * width + extraBytes;
|
|
51
|
-
for (var y = 0; y < height; y++) {
|
|
52
|
-
for (var x = 0; x < width; x++) {
|
|
53
|
-
var p = pos + y * rowBytes + x * 3;
|
|
54
|
-
i++; // a
|
|
55
|
-
tempBuffer[p] = buffer[i++]; // b
|
|
56
|
-
tempBuffer[p + 1] = buffer[i++]; // g
|
|
57
|
-
tempBuffer[p + 2] = buffer[i++]; // r
|
|
58
|
-
}
|
|
59
|
-
if (extraBytes > 0) {
|
|
60
|
-
var fillOffset = pos + y * rowBytes + width * 3;
|
|
61
|
-
tempBuffer.fill(0, fillOffset, fillOffset + extraBytes);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
shiftPos: pos,
|
|
66
|
-
rowBytes: rowBytes,
|
|
67
|
-
data: tempBuffer
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
exports.createBgrFrameEncoder = function (imgData) {
|
|
72
|
-
var width = imgData.width;
|
|
73
|
-
var height = imgData.height;
|
|
74
|
-
var extraBytes = width % 4;
|
|
75
|
-
var rowBytes = 3 * width + extraBytes;
|
|
76
|
-
var rgbSize = height * rowBytes;
|
|
77
|
-
var offset = 54;
|
|
78
|
-
var tempBuffer = Buffer.alloc(offset + rgbSize);
|
|
79
|
-
var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
|
|
80
|
-
return function (bgrBuffer) {
|
|
81
|
-
if (extraBytes === 0) {
|
|
82
|
-
bgrBuffer.copy(tempBuffer, pos, 0, width * height * 3);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
for (var y = 0; y < height; y++) {
|
|
86
|
-
var srcOffset = y * width * 3;
|
|
87
|
-
var dstOffset = pos + y * rowBytes;
|
|
88
|
-
bgrBuffer.copy(tempBuffer, dstOffset, srcOffset, srcOffset + width * 3);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
shiftPos: pos,
|
|
93
|
-
rowBytes: rowBytes,
|
|
94
|
-
data: tempBuffer
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var writeBmpHeader = function (buffer, width, height, rgbSize) {
|
|
4
|
+
var headerInfoSize = 40;
|
|
5
|
+
var offset = 54;
|
|
6
|
+
var fileSize = rgbSize + offset;
|
|
7
|
+
var pos = 0;
|
|
8
|
+
buffer.write('BM', pos, 2);
|
|
9
|
+
pos += 2;
|
|
10
|
+
buffer.writeUInt32LE(fileSize, pos);
|
|
11
|
+
pos += 4;
|
|
12
|
+
buffer.writeUInt32LE(0, pos);
|
|
13
|
+
pos += 4;
|
|
14
|
+
buffer.writeUInt32LE(offset, pos);
|
|
15
|
+
pos += 4;
|
|
16
|
+
buffer.writeUInt32LE(headerInfoSize, pos);
|
|
17
|
+
pos += 4;
|
|
18
|
+
buffer.writeUInt32LE(width, pos);
|
|
19
|
+
pos += 4;
|
|
20
|
+
buffer.writeInt32LE(-height, pos);
|
|
21
|
+
pos += 4;
|
|
22
|
+
buffer.writeUInt16LE(1, pos);
|
|
23
|
+
pos += 2;
|
|
24
|
+
buffer.writeUInt16LE(24, pos);
|
|
25
|
+
pos += 2;
|
|
26
|
+
buffer.writeUInt32LE(0, pos);
|
|
27
|
+
pos += 4;
|
|
28
|
+
buffer.writeUInt32LE(rgbSize, pos);
|
|
29
|
+
pos += 4;
|
|
30
|
+
buffer.writeUInt32LE(0, pos);
|
|
31
|
+
pos += 4;
|
|
32
|
+
buffer.writeUInt32LE(0, pos);
|
|
33
|
+
pos += 4;
|
|
34
|
+
buffer.writeUInt32LE(0, pos);
|
|
35
|
+
pos += 4;
|
|
36
|
+
buffer.writeUInt32LE(0, pos);
|
|
37
|
+
pos += 4;
|
|
38
|
+
return offset;
|
|
39
|
+
};
|
|
40
|
+
exports.createBpmEncoder = function (imgData) {
|
|
41
|
+
var width = imgData.width;
|
|
42
|
+
var height = imgData.height;
|
|
43
|
+
var extraBytes = width % 4;
|
|
44
|
+
var rgbSize = height * (3 * width + extraBytes);
|
|
45
|
+
var offset = 54;
|
|
46
|
+
return function (buffer) {
|
|
47
|
+
var tempBuffer = Buffer.alloc(offset + rgbSize);
|
|
48
|
+
var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
|
|
49
|
+
var i = 0;
|
|
50
|
+
var rowBytes = 3 * width + extraBytes;
|
|
51
|
+
for (var y = 0; y < height; y++) {
|
|
52
|
+
for (var x = 0; x < width; x++) {
|
|
53
|
+
var p = pos + y * rowBytes + x * 3;
|
|
54
|
+
i++; // a
|
|
55
|
+
tempBuffer[p] = buffer[i++]; // b
|
|
56
|
+
tempBuffer[p + 1] = buffer[i++]; // g
|
|
57
|
+
tempBuffer[p + 2] = buffer[i++]; // r
|
|
58
|
+
}
|
|
59
|
+
if (extraBytes > 0) {
|
|
60
|
+
var fillOffset = pos + y * rowBytes + width * 3;
|
|
61
|
+
tempBuffer.fill(0, fillOffset, fillOffset + extraBytes);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
shiftPos: pos,
|
|
66
|
+
rowBytes: rowBytes,
|
|
67
|
+
data: tempBuffer
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
exports.createBgrFrameEncoder = function (imgData) {
|
|
72
|
+
var width = imgData.width;
|
|
73
|
+
var height = imgData.height;
|
|
74
|
+
var extraBytes = width % 4;
|
|
75
|
+
var rowBytes = 3 * width + extraBytes;
|
|
76
|
+
var rgbSize = height * rowBytes;
|
|
77
|
+
var offset = 54;
|
|
78
|
+
var tempBuffer = Buffer.alloc(offset + rgbSize);
|
|
79
|
+
var pos = writeBmpHeader(tempBuffer, width, height, rgbSize);
|
|
80
|
+
return function (bgrBuffer) {
|
|
81
|
+
if (extraBytes === 0) {
|
|
82
|
+
bgrBuffer.copy(tempBuffer, pos, 0, width * height * 3);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
for (var y = 0; y < height; y++) {
|
|
86
|
+
var srcOffset = y * width * 3;
|
|
87
|
+
var dstOffset = pos + y * rowBytes;
|
|
88
|
+
bgrBuffer.copy(tempBuffer, dstOffset, srcOffset, srcOffset + width * 3);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
shiftPos: pos,
|
|
93
|
+
rowBytes: rowBytes,
|
|
94
|
+
data: tempBuffer
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
98
|
//# sourceMappingURL=bpmEncoder.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import { Config } from './index';
|
|
2
|
-
export declare const defaults: {
|
|
3
|
-
fps: number;
|
|
4
|
-
spectrumWidth: string;
|
|
5
|
-
spectrumHeight: number;
|
|
6
|
-
spectrumX: string;
|
|
7
|
-
spectrumY: string;
|
|
8
|
-
spectrumRotation: string;
|
|
9
|
-
spectrumBusMargin: number;
|
|
10
|
-
spectrumOpacity: string;
|
|
11
|
-
polarX: string;
|
|
12
|
-
polarY: string;
|
|
13
|
-
polarInnerRadius: number;
|
|
14
|
-
polarMaxBarLength: number;
|
|
15
|
-
polarBarWidth: number;
|
|
16
|
-
};
|
|
17
|
-
export declare type SpectrumEffect = 'volume' | 'smooth';
|
|
18
|
-
export declare const rotationAliasValues: readonly ["up", "down", "mirror"];
|
|
19
|
-
export declare const checkIsPercentValue: (value: string) => boolean;
|
|
20
|
-
export declare const getAudioFilePath: (config: Config) => string;
|
|
21
|
-
export declare const getAudioAutoHighlight: (config: Config) => boolean;
|
|
22
|
-
export declare const getAudioAutoHighlightCount: (config: Config) => number;
|
|
23
|
-
export declare const getBackgroundImagePath: (config: Config) => string | undefined;
|
|
24
|
-
export declare const getBackgroundVideoPath: (config: Config) => string | undefined;
|
|
25
|
-
export declare const getAutoEditVideo: (config: Config) => boolean;
|
|
26
|
-
export declare const getOutVideoPath: (config: Config) => string;
|
|
27
|
-
export declare type SubtitleAlignment = 'top' | 'middle' | 'bottom';
|
|
28
|
-
export declare type SubtitleRenderSpec = {
|
|
29
|
-
source: {
|
|
30
|
-
kind: 'file';
|
|
31
|
-
path: string;
|
|
32
|
-
} | {
|
|
33
|
-
kind: 'inline';
|
|
34
|
-
text: string;
|
|
35
|
-
};
|
|
36
|
-
alignment: SubtitleAlignment;
|
|
37
|
-
};
|
|
38
|
-
export declare const subtitleAlignmentToAss: (alignment: "top" | "middle" | "bottom") => number;
|
|
39
|
-
export declare const getSubtitleRenderSpec: (config: Config) => SubtitleRenderSpec | undefined;
|
|
40
|
-
export declare const getFPS: (config: Config) => number;
|
|
41
|
-
export declare const getOutputResolution: (config: Config) => {
|
|
42
|
-
width: number;
|
|
43
|
-
height: number;
|
|
44
|
-
} | undefined;
|
|
45
|
-
export declare const getSpectrumBusMargin: () => number;
|
|
46
|
-
export declare const getSpectrumEffect: (config: Config) => "smooth" | "volume" | undefined;
|
|
47
|
-
export declare const getSpectrumWidthAbsolute: (config: Config, backgroundImageWidth: number) => number;
|
|
48
|
-
export declare const getSpectrumHeightAbsolute: (config: Config, backgroundImageHeight: number) => number;
|
|
49
|
-
export declare const getSpectrumXAbsolute: (config: Config, spectrumWidth: number, backgroundImageWidth: number) => number;
|
|
50
|
-
export declare const getSpectrumYAbsolute: (config: Config, spectrumHeight: number, backgroundImageHeight: number) => number;
|
|
51
|
-
export declare const checkIsValidRotationAlias: (aliasName: string) => boolean;
|
|
52
|
-
export declare const getSpectrumRotation: (config: Config) => "up" | "down" | "mirror";
|
|
53
|
-
export declare const getSpectrumColor: (config: Config) => string | import("./image").Color | undefined;
|
|
54
|
-
export declare const getSpectrumOpacity: (config: Config) => string;
|
|
55
|
-
export declare const getSpectrumOpacityParsed: (config: Config) => number;
|
|
56
|
-
export declare const getFfmpeg_cfr: (config: Config) => string | undefined;
|
|
57
|
-
export declare const getFfmpeg_preset: (config: Config) => string | undefined;
|
|
58
|
-
export declare const getFrame_processing_delay: (config: Config) => number | undefined;
|
|
59
|
-
export declare const getPolarXAbsolute: (config: Config, backgroundImageWidth: number) => number;
|
|
60
|
-
export declare const getPolarYAbsolute: (config: Config, backgroundImageHeight: number) => number;
|
|
61
|
-
export declare const getPolarInnerRadius: (config: Config) => number;
|
|
62
|
-
export declare const getPolarMaxBarLength: (config: Config) => number;
|
|
63
|
-
export declare const getPolarBarWidth: (config: Config) => number;
|
|
64
|
-
export declare const getPolarEffect: (config: Config) => "smooth" | "volume" | undefined;
|
|
65
|
-
export declare const getPolarColor: (config: Config) => string | import("./image").Color | undefined;
|
|
66
|
-
export declare const getPolarOpacity: (config: Config) => string;
|
|
67
|
-
export declare const getPolarOpacityParsed: (config: Config) => number;
|
|
1
|
+
import { Config } from './index';
|
|
2
|
+
export declare const defaults: {
|
|
3
|
+
fps: number;
|
|
4
|
+
spectrumWidth: string;
|
|
5
|
+
spectrumHeight: number;
|
|
6
|
+
spectrumX: string;
|
|
7
|
+
spectrumY: string;
|
|
8
|
+
spectrumRotation: string;
|
|
9
|
+
spectrumBusMargin: number;
|
|
10
|
+
spectrumOpacity: string;
|
|
11
|
+
polarX: string;
|
|
12
|
+
polarY: string;
|
|
13
|
+
polarInnerRadius: number;
|
|
14
|
+
polarMaxBarLength: number;
|
|
15
|
+
polarBarWidth: number;
|
|
16
|
+
};
|
|
17
|
+
export declare type SpectrumEffect = 'volume' | 'smooth';
|
|
18
|
+
export declare const rotationAliasValues: readonly ["up", "down", "mirror"];
|
|
19
|
+
export declare const checkIsPercentValue: (value: string) => boolean;
|
|
20
|
+
export declare const getAudioFilePath: (config: Config) => string;
|
|
21
|
+
export declare const getAudioAutoHighlight: (config: Config) => boolean;
|
|
22
|
+
export declare const getAudioAutoHighlightCount: (config: Config) => number;
|
|
23
|
+
export declare const getBackgroundImagePath: (config: Config) => string | undefined;
|
|
24
|
+
export declare const getBackgroundVideoPath: (config: Config) => string | undefined;
|
|
25
|
+
export declare const getAutoEditVideo: (config: Config) => boolean;
|
|
26
|
+
export declare const getOutVideoPath: (config: Config) => string;
|
|
27
|
+
export declare type SubtitleAlignment = 'top' | 'middle' | 'bottom';
|
|
28
|
+
export declare type SubtitleRenderSpec = {
|
|
29
|
+
source: {
|
|
30
|
+
kind: 'file';
|
|
31
|
+
path: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'inline';
|
|
34
|
+
text: string;
|
|
35
|
+
};
|
|
36
|
+
alignment: SubtitleAlignment;
|
|
37
|
+
};
|
|
38
|
+
export declare const subtitleAlignmentToAss: (alignment: "top" | "middle" | "bottom") => number;
|
|
39
|
+
export declare const getSubtitleRenderSpec: (config: Config) => SubtitleRenderSpec | undefined;
|
|
40
|
+
export declare const getFPS: (config: Config) => number;
|
|
41
|
+
export declare const getOutputResolution: (config: Config) => {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
} | undefined;
|
|
45
|
+
export declare const getSpectrumBusMargin: () => number;
|
|
46
|
+
export declare const getSpectrumEffect: (config: Config) => "smooth" | "volume" | undefined;
|
|
47
|
+
export declare const getSpectrumWidthAbsolute: (config: Config, backgroundImageWidth: number) => number;
|
|
48
|
+
export declare const getSpectrumHeightAbsolute: (config: Config, backgroundImageHeight: number) => number;
|
|
49
|
+
export declare const getSpectrumXAbsolute: (config: Config, spectrumWidth: number, backgroundImageWidth: number) => number;
|
|
50
|
+
export declare const getSpectrumYAbsolute: (config: Config, spectrumHeight: number, backgroundImageHeight: number) => number;
|
|
51
|
+
export declare const checkIsValidRotationAlias: (aliasName: string) => boolean;
|
|
52
|
+
export declare const getSpectrumRotation: (config: Config) => "up" | "down" | "mirror";
|
|
53
|
+
export declare const getSpectrumColor: (config: Config) => string | import("./image").Color | undefined;
|
|
54
|
+
export declare const getSpectrumOpacity: (config: Config) => string;
|
|
55
|
+
export declare const getSpectrumOpacityParsed: (config: Config) => number;
|
|
56
|
+
export declare const getFfmpeg_cfr: (config: Config) => string | undefined;
|
|
57
|
+
export declare const getFfmpeg_preset: (config: Config) => string | undefined;
|
|
58
|
+
export declare const getFrame_processing_delay: (config: Config) => number | undefined;
|
|
59
|
+
export declare const getPolarXAbsolute: (config: Config, backgroundImageWidth: number) => number;
|
|
60
|
+
export declare const getPolarYAbsolute: (config: Config, backgroundImageHeight: number) => number;
|
|
61
|
+
export declare const getPolarInnerRadius: (config: Config) => number;
|
|
62
|
+
export declare const getPolarMaxBarLength: (config: Config) => number;
|
|
63
|
+
export declare const getPolarBarWidth: (config: Config) => number;
|
|
64
|
+
export declare const getPolarEffect: (config: Config) => "smooth" | "volume" | undefined;
|
|
65
|
+
export declare const getPolarColor: (config: Config) => string | import("./image").Color | undefined;
|
|
66
|
+
export declare const getPolarOpacity: (config: Config) => string;
|
|
67
|
+
export declare const getPolarOpacityParsed: (config: Config) => number;
|