nodejs-audio-visualizer 4.0.0 → 4.1.1
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/README.md +9 -8
- package/dist/beats.d.ts +19 -0
- package/dist/beats.js +44 -0
- package/dist/beats.js.map +1 -0
- package/dist/bpmEncoder.d.ts +4 -0
- package/dist/bpmEncoder.js +65 -43
- package/dist/bpmEncoder.js.map +1 -1
- package/dist/config.d.ts +7 -1
- package/dist/config.js +8 -1
- package/dist/config.js.map +1 -1
- package/dist/image.d.ts +2 -1
- package/dist/image.js +42 -5
- package/dist/image.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +217 -50
- package/dist/index.js.map +1 -1
- package/dist/video.d.ts +41 -1
- package/dist/video.js +244 -0
- package/dist/video.js.map +1 -1
- package/package.json +2 -2
- package/src/beats.ts +68 -0
- package/src/bpmEncoder.ts +57 -31
- package/src/config.ts +10 -1
- package/src/image.ts +46 -4
- package/src/index.ts +262 -34
- package/src/video.ts +302 -1
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ var audio_1 = require("./audio");
|
|
|
52
52
|
var image_1 = require("./image");
|
|
53
53
|
var video_1 = require("./video");
|
|
54
54
|
var bpmEncoder_1 = require("./bpmEncoder");
|
|
55
|
+
var beats_1 = require("./beats");
|
|
55
56
|
exports.PCM_FORMAT = {
|
|
56
57
|
bit: 8,
|
|
57
58
|
sign: 'u',
|
|
@@ -62,54 +63,195 @@ var PROCESSING_BUFFER_SIZE = Math.pow(2, 12);
|
|
|
62
63
|
var sleep = function (timeout) {
|
|
63
64
|
return new Promise(function (resolve) { return setTimeout(resolve, timeout); });
|
|
64
65
|
};
|
|
65
|
-
var createVisualizerFrameGenerator = function (config,
|
|
66
|
+
var createVisualizerFrameGenerator = function (config, backgroundWidth, backgroundHeight, defaultColor, spectrumBusMargin) {
|
|
66
67
|
if (!config.outVideo.spectrum) {
|
|
67
68
|
var createPolarVisualizerFrame_1 = image_1.createPolarVisualizerFrameGenerator();
|
|
68
|
-
var polarX_1 = config_1.getPolarXAbsolute(config,
|
|
69
|
-
var polarY_1 = config_1.getPolarYAbsolute(config,
|
|
69
|
+
var polarX_1 = config_1.getPolarXAbsolute(config, backgroundWidth);
|
|
70
|
+
var polarY_1 = config_1.getPolarYAbsolute(config, backgroundHeight);
|
|
70
71
|
var polarInnerRadius_1 = config_1.getPolarInnerRadius(config);
|
|
71
72
|
var polarMaxBarLength_1 = config_1.getPolarMaxBarLength(config);
|
|
72
73
|
var polarBarWidth_1 = config_1.getPolarBarWidth(config);
|
|
73
|
-
var polarColor_1 = config_1.getPolarColor(config) || image_1.invertColor(
|
|
74
|
+
var polarColor_1 = config_1.getPolarColor(config) || image_1.invertColor(defaultColor);
|
|
74
75
|
var polarEffect_1 = config_1.getPolarEffect(config);
|
|
75
76
|
var polarOpacity_1 = config_1.getPolarOpacityParsed(config);
|
|
76
77
|
return function (params) {
|
|
77
78
|
return createPolarVisualizerFrame_1(__assign(__assign({}, params), { centerX: polarX_1, centerY: polarY_1, innerRadius: polarInnerRadius_1, maxBarLength: polarMaxBarLength_1, barWidth: polarBarWidth_1, color: polarColor_1, opacity: polarOpacity_1, spectrumEffect: polarEffect_1 }));
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
var
|
|
81
|
-
var spectrumWidth = config_1.getSpectrumWidthAbsolute(config,
|
|
82
|
-
var spectrumHeight = config_1.getSpectrumHeightAbsolute(config,
|
|
83
|
-
var spectrumX = config_1.getSpectrumXAbsolute(config, spectrumWidth,
|
|
84
|
-
var spectrumY = config_1.getSpectrumYAbsolute(config, spectrumHeight,
|
|
81
|
+
var createSpectrumVisualizerFrame = image_1.createSpectrumVisualizerFrameGenerator();
|
|
82
|
+
var spectrumWidth = config_1.getSpectrumWidthAbsolute(config, backgroundWidth);
|
|
83
|
+
var spectrumHeight = config_1.getSpectrumHeightAbsolute(config, backgroundHeight);
|
|
84
|
+
var spectrumX = config_1.getSpectrumXAbsolute(config, spectrumWidth, backgroundWidth);
|
|
85
|
+
var spectrumY = config_1.getSpectrumYAbsolute(config, spectrumHeight, backgroundHeight);
|
|
85
86
|
var spectrumRotation = config_1.getSpectrumRotation(config);
|
|
86
|
-
var spectrumColor = config_1.getSpectrumColor(config) || image_1.invertColor(
|
|
87
|
+
var spectrumColor = config_1.getSpectrumColor(config) || image_1.invertColor(defaultColor);
|
|
87
88
|
var spectrumEffect = config_1.getSpectrumEffect(config);
|
|
88
89
|
var spectrumOpacity = config_1.getSpectrumOpacityParsed(config);
|
|
89
90
|
return function (params) {
|
|
90
|
-
return
|
|
91
|
+
return createSpectrumVisualizerFrame(__assign(__assign({}, params), { size: { width: spectrumWidth, height: spectrumHeight }, position: { x: spectrumX, y: spectrumY }, rotation: spectrumRotation, margin: spectrumBusMargin, color: spectrumColor, opacity: spectrumOpacity, spectrumEffect: spectrumEffect }));
|
|
91
92
|
};
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
var PREPROCESS_YIELD_EVERY = 256;
|
|
95
|
+
var preProcessAudio = function (audioBuffer, sampleRate, fps, framesCount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
var audioDataStep, processingBuffer, skipFramesCount, processSpectrum, detectBeat, spectrums, beatFrameIndices, i, currentFrameData, audioDataParser, spectrum, beat;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
audioDataStep = Math.trunc(audioBuffer.length / framesCount);
|
|
101
|
+
processingBuffer = new Float32Array(PROCESSING_BUFFER_SIZE).fill(0);
|
|
102
|
+
skipFramesCount = fps < 45 ? 1 : 2;
|
|
103
|
+
processSpectrum = audio_1.createSpectrumsProcessor(sampleRate, skipFramesCount);
|
|
104
|
+
detectBeat = beats_1.createBeatDetector(fps);
|
|
105
|
+
spectrums = [];
|
|
106
|
+
beatFrameIndices = [];
|
|
107
|
+
i = 0;
|
|
108
|
+
_a.label = 1;
|
|
109
|
+
case 1:
|
|
110
|
+
if (!(i < framesCount)) return [3 /*break*/, 4];
|
|
111
|
+
currentFrameData = exports.PCM_FORMAT.parseFunction(audioBuffer, i * audioDataStep, i * audioDataStep + audioDataStep);
|
|
112
|
+
processingBuffer.copyWithin(0, currentFrameData.length);
|
|
113
|
+
processingBuffer.set(currentFrameData, PROCESSING_BUFFER_SIZE - currentFrameData.length);
|
|
114
|
+
audioDataParser = function () { return Array.from(processingBuffer); };
|
|
115
|
+
spectrum = processSpectrum(audioDataParser);
|
|
116
|
+
beat = detectBeat(spectrum);
|
|
117
|
+
spectrums.push(spectrum);
|
|
118
|
+
if (beat.isBeat) {
|
|
119
|
+
beatFrameIndices.push(i);
|
|
120
|
+
}
|
|
121
|
+
if (!((i + 1) % PREPROCESS_YIELD_EVERY === 0)) return [3 /*break*/, 3];
|
|
122
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setImmediate(resolve); })];
|
|
123
|
+
case 2:
|
|
124
|
+
_a.sent();
|
|
125
|
+
_a.label = 3;
|
|
126
|
+
case 3:
|
|
127
|
+
i++;
|
|
128
|
+
return [3 /*break*/, 1];
|
|
129
|
+
case 4: return [2 /*return*/, { spectrums: spectrums, beatFrameIndices: beatFrameIndices }];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); };
|
|
133
|
+
function prepareBackgroundForRender(params) {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var useVideoBackground, backgroundVideoPath, backgroundImagePath, beatFrameIndices, framesCount, outputResolution, fps, autoEditVideo, videoInfo, sceneChanges, _g, backgroundWidth_1, backgroundHeight_1, videoFrameSize, encodeVideoFrame, segments, concatFilePath, videoFrameReader, firstFrame, defaultColor_1, staticBackgroundBuffer_1, backgroundImageBmpBuffer, backgroundImage, backgroundWidth, backgroundHeight, defaultColor, bpmEncoder, staticBackgroundBuffer;
|
|
137
|
+
return __generator(this, function (_h) {
|
|
138
|
+
switch (_h.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
useVideoBackground = params.useVideoBackground, backgroundVideoPath = params.backgroundVideoPath, backgroundImagePath = params.backgroundImagePath, beatFrameIndices = params.beatFrameIndices, framesCount = params.framesCount, outputResolution = params.outputResolution, fps = params.fps, autoEditVideo = params.autoEditVideo;
|
|
141
|
+
if (!(useVideoBackground && backgroundVideoPath)) return [3 /*break*/, 6];
|
|
142
|
+
return [4 /*yield*/, video_1.getVideoInfo(backgroundVideoPath)];
|
|
143
|
+
case 1:
|
|
144
|
+
videoInfo = _h.sent();
|
|
145
|
+
if (!autoEditVideo) return [3 /*break*/, 3];
|
|
146
|
+
return [4 /*yield*/, video_1.detectSceneChanges(backgroundVideoPath)];
|
|
147
|
+
case 2:
|
|
148
|
+
_g = _h.sent();
|
|
149
|
+
return [3 /*break*/, 4];
|
|
150
|
+
case 3:
|
|
151
|
+
_g = [];
|
|
152
|
+
_h.label = 4;
|
|
153
|
+
case 4:
|
|
154
|
+
sceneChanges = _g;
|
|
155
|
+
backgroundWidth_1 = (_b = (_a = outputResolution) === null || _a === void 0 ? void 0 : _a.width, (_b !== null && _b !== void 0 ? _b : videoInfo.width));
|
|
156
|
+
backgroundHeight_1 = (_d = (_c = outputResolution) === null || _c === void 0 ? void 0 : _c.height, (_d !== null && _d !== void 0 ? _d : videoInfo.height));
|
|
157
|
+
videoFrameSize = backgroundWidth_1 * backgroundHeight_1 * 3;
|
|
158
|
+
encodeVideoFrame = bpmEncoder_1.createBgrFrameEncoder({ width: backgroundWidth_1, height: backgroundHeight_1 });
|
|
159
|
+
segments = video_1.buildBeatSyncedSegments(beatFrameIndices, framesCount, sceneChanges, videoInfo.duration);
|
|
160
|
+
concatFilePath = video_1.writeConcatFile(segments, backgroundVideoPath, videoInfo.duration, fps);
|
|
161
|
+
videoFrameReader = video_1.spawnConcatVideoFrameReader(__assign({ concatFilePath: concatFilePath,
|
|
162
|
+
fps: fps, totalFrames: framesCount }, (outputResolution && {
|
|
163
|
+
width: backgroundWidth_1,
|
|
164
|
+
height: backgroundHeight_1,
|
|
165
|
+
sourceWidth: videoInfo.width,
|
|
166
|
+
sourceHeight: videoInfo.height,
|
|
167
|
+
})));
|
|
168
|
+
return [4 /*yield*/, video_1.readVideoFrame(videoFrameReader.stdout, videoFrameSize)];
|
|
169
|
+
case 5:
|
|
170
|
+
firstFrame = _h.sent();
|
|
171
|
+
if (!firstFrame) {
|
|
172
|
+
throw new Error("Could not read frames from video: " + backgroundVideoPath);
|
|
173
|
+
}
|
|
174
|
+
defaultColor_1 = image_1.getVideoFrameColor(firstFrame, backgroundWidth_1, backgroundHeight_1);
|
|
175
|
+
staticBackgroundBuffer_1 = encodeVideoFrame(firstFrame);
|
|
176
|
+
return [2 /*return*/, {
|
|
177
|
+
backgroundWidth: backgroundWidth_1,
|
|
178
|
+
backgroundHeight: backgroundHeight_1,
|
|
179
|
+
defaultColor: defaultColor_1,
|
|
180
|
+
staticBackgroundBuffer: staticBackgroundBuffer_1,
|
|
181
|
+
videoFrameReader: videoFrameReader,
|
|
182
|
+
videoFrameSize: videoFrameSize,
|
|
183
|
+
encodeVideoFrame: encodeVideoFrame,
|
|
184
|
+
concatFilePath: concatFilePath,
|
|
185
|
+
}];
|
|
186
|
+
case 6:
|
|
187
|
+
if (!backgroundImagePath) {
|
|
188
|
+
throw new Error('Background image path is required when not using video background.');
|
|
189
|
+
}
|
|
190
|
+
return [4 /*yield*/, image_1.convertToBmp(backgroundImagePath, (_e = outputResolution) === null || _e === void 0 ? void 0 : _e.width, (_f = outputResolution) === null || _f === void 0 ? void 0 : _f.height)];
|
|
191
|
+
case 7:
|
|
192
|
+
backgroundImageBmpBuffer = _h.sent();
|
|
193
|
+
backgroundImage = image_1.parseImage(backgroundImageBmpBuffer);
|
|
194
|
+
backgroundWidth = backgroundImage.width;
|
|
195
|
+
backgroundHeight = backgroundImage.height;
|
|
196
|
+
defaultColor = image_1.getImageColor(backgroundImage);
|
|
197
|
+
bpmEncoder = bpmEncoder_1.createBpmEncoder({ width: backgroundWidth, height: backgroundHeight });
|
|
198
|
+
staticBackgroundBuffer = bpmEncoder(backgroundImage.data);
|
|
199
|
+
return [2 /*return*/, {
|
|
200
|
+
backgroundWidth: backgroundWidth,
|
|
201
|
+
backgroundHeight: backgroundHeight,
|
|
202
|
+
defaultColor: defaultColor,
|
|
203
|
+
staticBackgroundBuffer: staticBackgroundBuffer,
|
|
204
|
+
videoFrameSize: 0,
|
|
205
|
+
}];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function resolveBackgroundFrameBuffer(params) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
212
|
+
var frameIndex, useVideoBackground, videoFrameReader, videoFrameSize, encodeVideoFrame, staticBackgroundBuffer, videoFrame;
|
|
96
213
|
return __generator(this, function (_a) {
|
|
97
214
|
switch (_a.label) {
|
|
98
215
|
case 0:
|
|
99
|
-
|
|
216
|
+
frameIndex = params.frameIndex, useVideoBackground = params.useVideoBackground, videoFrameReader = params.videoFrameReader, videoFrameSize = params.videoFrameSize, encodeVideoFrame = params.encodeVideoFrame, staticBackgroundBuffer = params.staticBackgroundBuffer;
|
|
217
|
+
if (!(useVideoBackground && videoFrameReader && encodeVideoFrame)) return [3 /*break*/, 2];
|
|
218
|
+
if (frameIndex === 0) {
|
|
219
|
+
return [2 /*return*/, staticBackgroundBuffer];
|
|
220
|
+
}
|
|
221
|
+
return [4 /*yield*/, video_1.readVideoFrame(videoFrameReader.stdout, videoFrameSize)];
|
|
222
|
+
case 1:
|
|
223
|
+
videoFrame = _a.sent();
|
|
224
|
+
return [2 /*return*/, videoFrame
|
|
225
|
+
? encodeVideoFrame(videoFrame)
|
|
226
|
+
: staticBackgroundBuffer];
|
|
227
|
+
case 2: return [2 /*return*/, staticBackgroundBuffer];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
exports.renderAudioVisualizer = function (config, onProgress, shouldStop) {
|
|
233
|
+
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
+
var audioFilePath, outVideoPath, backgroundVideoPath, backgroundImagePath, useVideoBackground, audioReader, audioBuffer, sampleRate, spectrumBusMargin, FPS, ffmpeg_cfr, ffmpeg_preset, frame_processing_delay, audioDuration, framesCount, outputResolution, preprocessed, _a, backgroundWidth, backgroundHeight, defaultColor, staticBackgroundBuffer, videoFrameReader, videoFrameSize, encodeVideoFrame, concatFilePath, createVisualizerFrame, ffmpegVideoWriter, i, spectrum, backgroundImageBuffer, commonVisualizerFrameProps, frameImage, isFrameProcessed;
|
|
235
|
+
return __generator(this, function (_b) {
|
|
236
|
+
switch (_b.label) {
|
|
237
|
+
case 0:
|
|
100
238
|
if (config.outVideo.spectrum && config.outVideo.polar) {
|
|
101
239
|
throw new Error('Cannot use both "spectrum" and "polar" options. Please specify only one visualizer type.');
|
|
102
240
|
}
|
|
241
|
+
if (!config.image && !config.video) {
|
|
242
|
+
throw new Error('Either "image" or "video" must be specified as the background source.');
|
|
243
|
+
}
|
|
244
|
+
if (config.image && config.video) {
|
|
245
|
+
throw new Error('Cannot use both "image" and "video" options. Please specify only one background source.');
|
|
246
|
+
}
|
|
103
247
|
audioFilePath = config_1.getAudioFilePath(config);
|
|
104
|
-
backgroundImagePath = config_1.getBackgroundImagePath(config);
|
|
105
248
|
outVideoPath = config_1.getOutVideoPath(config);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
backgroundImage = image_1.parseImage(backgroundImageBmpBuffer);
|
|
249
|
+
backgroundVideoPath = config_1.getBackgroundVideoPath(config);
|
|
250
|
+
backgroundImagePath = config_1.getBackgroundImagePath(config);
|
|
251
|
+
useVideoBackground = !!backgroundVideoPath;
|
|
110
252
|
return [4 /*yield*/, audio_1.createAudioBuffer(audioFilePath, FFMPEG_FORMAT)];
|
|
111
|
-
case
|
|
112
|
-
audioReader =
|
|
253
|
+
case 1:
|
|
254
|
+
audioReader = _b.sent();
|
|
113
255
|
audioBuffer = audioReader.audioBuffer;
|
|
114
256
|
sampleRate = audioReader.sampleRate;
|
|
115
257
|
if (!sampleRate) {
|
|
@@ -120,50 +262,75 @@ exports.renderAudioVisualizer = function (config, onProgress, shouldStop) {
|
|
|
120
262
|
ffmpeg_cfr = config_1.getFfmpeg_cfr(config);
|
|
121
263
|
ffmpeg_preset = config_1.getFfmpeg_preset(config);
|
|
122
264
|
frame_processing_delay = config_1.getFrame_processing_delay(config);
|
|
123
|
-
createVisualizerFrame = createVisualizerFrameGenerator(config, backgroundImage, spectrumBusMargin);
|
|
124
265
|
audioDuration = audioBuffer.length / sampleRate;
|
|
125
266
|
framesCount = Math.trunc(audioDuration * FPS);
|
|
126
|
-
|
|
127
|
-
|
|
267
|
+
outputResolution = config_1.getOutputResolution(config);
|
|
268
|
+
if (onProgress) {
|
|
269
|
+
onProgress(0);
|
|
270
|
+
}
|
|
271
|
+
return [4 /*yield*/, preProcessAudio(audioBuffer, sampleRate, FPS, framesCount)];
|
|
272
|
+
case 2:
|
|
273
|
+
preprocessed = _b.sent();
|
|
274
|
+
return [4 /*yield*/, prepareBackgroundForRender({
|
|
275
|
+
useVideoBackground: useVideoBackground,
|
|
276
|
+
backgroundVideoPath: backgroundVideoPath,
|
|
277
|
+
backgroundImagePath: backgroundImagePath,
|
|
278
|
+
beatFrameIndices: preprocessed.beatFrameIndices,
|
|
279
|
+
framesCount: framesCount,
|
|
280
|
+
outputResolution: outputResolution,
|
|
281
|
+
fps: FPS,
|
|
282
|
+
autoEditVideo: config_1.getAutoEditVideo(config),
|
|
283
|
+
})];
|
|
284
|
+
case 3:
|
|
285
|
+
_a = _b.sent(), backgroundWidth = _a.backgroundWidth, backgroundHeight = _a.backgroundHeight, defaultColor = _a.defaultColor, staticBackgroundBuffer = _a.staticBackgroundBuffer, videoFrameReader = _a.videoFrameReader, videoFrameSize = _a.videoFrameSize, encodeVideoFrame = _a.encodeVideoFrame, concatFilePath = _a.concatFilePath;
|
|
286
|
+
createVisualizerFrame = createVisualizerFrameGenerator(config, backgroundWidth, backgroundHeight, defaultColor, spectrumBusMargin);
|
|
128
287
|
ffmpegVideoWriter = video_1.spawnFfmpegVideoWriter(__assign(__assign(__assign({ audioFilename: audioFilePath, videoFileName: outVideoPath, fps: FPS }, (!!onProgress && { onStderr: video_1.getProgress(video_1.calculateProgress(framesCount + 1, onProgress)) })), (ffmpeg_cfr && { crf: ffmpeg_cfr })), (ffmpeg_preset && { preset: ffmpeg_preset })));
|
|
129
288
|
ffmpegVideoWriter.on('exit', function (code) { return resolve(code); });
|
|
130
|
-
bpmEncoder = bpmEncoder_1.createBpmEncoder({ width: backgroundImage.width, height: backgroundImage.height });
|
|
131
|
-
backgroundImageBuffer = bpmEncoder(backgroundImage.data);
|
|
132
|
-
skipFramesCount = FPS < 45 ? 1 : 2;
|
|
133
|
-
processSpectrum = audio_1.createSpectrumsProcessor(sampleRate, skipFramesCount);
|
|
134
289
|
i = 0;
|
|
135
|
-
|
|
136
|
-
case
|
|
137
|
-
if (!(i < framesCount)) return [3 /*break*/,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
290
|
+
_b.label = 4;
|
|
291
|
+
case 4:
|
|
292
|
+
if (!(i < framesCount)) return [3 /*break*/, 10];
|
|
293
|
+
spectrum = preprocessed.spectrums[i];
|
|
294
|
+
return [4 /*yield*/, resolveBackgroundFrameBuffer({
|
|
295
|
+
frameIndex: i,
|
|
296
|
+
useVideoBackground: useVideoBackground,
|
|
297
|
+
videoFrameReader: videoFrameReader,
|
|
298
|
+
videoFrameSize: videoFrameSize,
|
|
299
|
+
encodeVideoFrame: encodeVideoFrame,
|
|
300
|
+
staticBackgroundBuffer: staticBackgroundBuffer,
|
|
301
|
+
})];
|
|
302
|
+
case 5:
|
|
303
|
+
backgroundImageBuffer = _b.sent();
|
|
143
304
|
commonVisualizerFrameProps = {
|
|
144
305
|
backgroundImageBuffer: backgroundImageBuffer,
|
|
145
306
|
spectrum: spectrum,
|
|
146
307
|
};
|
|
147
308
|
frameImage = createVisualizerFrame(commonVisualizerFrameProps);
|
|
148
309
|
isFrameProcessed = ffmpegVideoWriter.stdin.write(frameImage.data);
|
|
149
|
-
if (!!isFrameProcessed) return [3 /*break*/,
|
|
310
|
+
if (!!isFrameProcessed) return [3 /*break*/, 7];
|
|
150
311
|
return [4 /*yield*/, video_1.waitDrain(ffmpegVideoWriter.stdin)];
|
|
151
|
-
case
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
case
|
|
312
|
+
case 6:
|
|
313
|
+
_b.sent();
|
|
314
|
+
_b.label = 7;
|
|
315
|
+
case 7:
|
|
155
316
|
if (shouldStop && shouldStop()) {
|
|
156
|
-
return [3 /*break*/,
|
|
317
|
+
return [3 /*break*/, 10];
|
|
157
318
|
}
|
|
158
|
-
if (!frame_processing_delay) return [3 /*break*/,
|
|
319
|
+
if (!frame_processing_delay) return [3 /*break*/, 9];
|
|
159
320
|
return [4 /*yield*/, sleep(frame_processing_delay)];
|
|
160
|
-
case 6:
|
|
161
|
-
_a.sent();
|
|
162
|
-
_a.label = 7;
|
|
163
|
-
case 7:
|
|
164
|
-
i++;
|
|
165
|
-
return [3 /*break*/, 3];
|
|
166
321
|
case 8:
|
|
322
|
+
_b.sent();
|
|
323
|
+
_b.label = 9;
|
|
324
|
+
case 9:
|
|
325
|
+
i++;
|
|
326
|
+
return [3 /*break*/, 4];
|
|
327
|
+
case 10:
|
|
328
|
+
if (videoFrameReader) {
|
|
329
|
+
videoFrameReader.kill();
|
|
330
|
+
}
|
|
331
|
+
if (concatFilePath) {
|
|
332
|
+
video_1.cleanupConcatFile(concatFilePath);
|
|
333
|
+
}
|
|
167
334
|
ffmpegVideoWriter.stdin.end();
|
|
168
335
|
return [2 /*return*/];
|
|
169
336
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCA8BkB;AAClB,iCAAqF;AACrF,iCAAgR;AAChR,iCAA+P;AAC/P,2CAAmF;AACnF,iCAA6C;AAGhC,QAAA,UAAU,GAAG;IACxB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,GAAG;IACT,aAAa,EAAE,qBAAa;CAC7B,CAAC;AACF,IAAM,aAAa,GAAG,KAAG,kBAAU,CAAC,IAAI,GAAG,kBAAU,CAAC,GAAK,CAAC;AAC5D,IAAM,sBAAsB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AA4D/C,IAAM,KAAK,GAAG,UAAC,OAAe;IAC5B,OAAA,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EAA5B,CAA4B,CAAC;AAApD,CAAoD,CAAC;AAEvD,IAAM,8BAA8B,GAAG,UACrC,MAAc,EACd,eAAuB,EACvB,gBAAwB,EACxB,YAAmB,EACnB,iBAAyB;IAEzB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC7B,IAAM,4BAA0B,GAAG,2CAAmC,EAAE,CAAC;QACzE,IAAM,QAAM,GAAG,0BAAiB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC1D,IAAM,QAAM,GAAG,0BAAiB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC3D,IAAM,kBAAgB,GAAG,4BAAmB,CAAC,MAAM,CAAC,CAAC;QACrD,IAAM,mBAAiB,GAAG,6BAAoB,CAAC,MAAM,CAA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AE,EAAE;wBAC9B,yBAAM;qBACP;yBACG,sBAAsB,EAAtB,wBAAsB;oBACxB,qBAAM,KAAK,CAAC,sBAAsB,CAAC,EAAA;;oBAAnC,SAAmC,CAAC;;;oBAzBP,CAAC,EAAE,CAAA;;;oBA6BpC,IAAI,gBAAgB,EAAE;wBACpB,gBAAgB,CAAC,IAAI,EAAE,CAAC;qBACzB;oBACD,IAAI,cAAc,EAAE;wBAClB,yBAAiB,CAAC,cAAc,CAAC,CAAC;qBACnC;oBACD,iBAAiB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;;;;SAC/B,CAAC;AA7GF,CA6GE,CAAC"}
|
package/dist/video.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Writable } from 'stream';
|
|
2
|
+
import { Readable, Writable } from 'stream';
|
|
3
3
|
interface FfmpegVideoWriterConfig {
|
|
4
4
|
audioFilename: string;
|
|
5
5
|
videoFileName: string;
|
|
@@ -9,7 +9,47 @@ interface FfmpegVideoWriterConfig {
|
|
|
9
9
|
onStderr?: (data: any) => any;
|
|
10
10
|
}
|
|
11
11
|
export declare const spawnFfmpegVideoWriter: (config: FfmpegVideoWriterConfig) => import("child_process").ChildProcessWithoutNullStreams;
|
|
12
|
+
export interface VideoInfo {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
duration: number;
|
|
16
|
+
}
|
|
17
|
+
export interface SceneChange {
|
|
18
|
+
frameNumber: number;
|
|
19
|
+
pts: number;
|
|
20
|
+
ptsTime: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const detectSceneChanges: (videoPath: string, threshold?: number) => Promise<SceneChange[]>;
|
|
23
|
+
export declare const getVideoInfo: (videoPath: string) => Promise<VideoInfo>;
|
|
24
|
+
export declare const buildVideoFilter: (sourceWidth: number, sourceHeight: number, targetWidth: number, targetHeight: number) => string;
|
|
25
|
+
export declare const spawnVideoFrameReader: (config: {
|
|
26
|
+
videoPath: string;
|
|
27
|
+
fps: number;
|
|
28
|
+
totalFrames: number;
|
|
29
|
+
width?: number | undefined;
|
|
30
|
+
height?: number | undefined;
|
|
31
|
+
sourceWidth?: number | undefined;
|
|
32
|
+
sourceHeight?: number | undefined;
|
|
33
|
+
}) => import("child_process").ChildProcessWithoutNullStreams;
|
|
34
|
+
export declare const readVideoFrame: (stream: Readable, frameSize: number) => Promise<Buffer | null>;
|
|
12
35
|
export declare const getProgress: (onProgress: (currentFrame: number) => any) => (stderrOutput: Buffer) => void;
|
|
13
36
|
export declare const calculateProgress: (framesCount: number, callback: (progress: number) => any) => (currentFrame: number) => any;
|
|
14
37
|
export declare const waitDrain: (stream: Writable) => Promise<void>;
|
|
38
|
+
export interface VideoSegment {
|
|
39
|
+
outputStartFrame: number;
|
|
40
|
+
videoSeekSeconds: number;
|
|
41
|
+
frameCount: number;
|
|
42
|
+
}
|
|
43
|
+
export declare const buildBeatSyncedSegments: (beatFrameIndices: number[], totalFrames: number, sceneChanges: SceneChange[], videoDuration: number) => VideoSegment[];
|
|
44
|
+
export declare const writeConcatFile: (segments: VideoSegment[], videoPath: string, videoDuration: number, fps: number) => string;
|
|
45
|
+
export declare const spawnConcatVideoFrameReader: (config: {
|
|
46
|
+
concatFilePath: string;
|
|
47
|
+
fps: number;
|
|
48
|
+
totalFrames: number;
|
|
49
|
+
width?: number | undefined;
|
|
50
|
+
height?: number | undefined;
|
|
51
|
+
sourceWidth?: number | undefined;
|
|
52
|
+
sourceHeight?: number | undefined;
|
|
53
|
+
}) => import("child_process").ChildProcessWithoutNullStreams;
|
|
54
|
+
export declare const cleanupConcatFile: (filePath: string) => void;
|
|
15
55
|
export {};
|