nodejs-audio-visualizer 3.0.0 → 4.1.0

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/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,22 +63,178 @@ 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
- exports.renderAudioVisualizer = function (config, onProgress, shouldStop) {
66
- return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
67
- var audioFilePath, backgroundImagePath, outVideoPath, backgroundImageBmpBuffer, backgroundImage, audioReader, audioBuffer, sampleRate, spectrumBusMargin, FPS, spectrumWidth, spectrumHeight, spectrumX, spectrumY, spectrumRotation, spectrumColor, spectrumEffect, spectrumOpacity, ffmpeg_cfr, ffmpeg_preset, frame_processing_delay, audioDuration, framesCount, audioDataStep, processingBuffer, ffmpegVideoWriter, bpmEncoder, backgroundImageBuffer, skipFramesCount, processSpectrum, createVisualizerFrame, i, currentFrameData, audioDataParser, spectrum, frameImage, isFrameProcessed;
66
+ var createVisualizerFrameGenerator = function (config, backgroundWidth, backgroundHeight, defaultColor, spectrumBusMargin) {
67
+ if (!config.outVideo.spectrum) {
68
+ var createPolarVisualizerFrame_1 = image_1.createPolarVisualizerFrameGenerator();
69
+ var polarX_1 = config_1.getPolarXAbsolute(config, backgroundWidth);
70
+ var polarY_1 = config_1.getPolarYAbsolute(config, backgroundHeight);
71
+ var polarInnerRadius_1 = config_1.getPolarInnerRadius(config);
72
+ var polarMaxBarLength_1 = config_1.getPolarMaxBarLength(config);
73
+ var polarBarWidth_1 = config_1.getPolarBarWidth(config);
74
+ var polarColor_1 = config_1.getPolarColor(config) || image_1.invertColor(defaultColor);
75
+ var polarEffect_1 = config_1.getPolarEffect(config);
76
+ var polarOpacity_1 = config_1.getPolarOpacityParsed(config);
77
+ return function (params) {
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 }));
79
+ };
80
+ }
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);
86
+ var spectrumRotation = config_1.getSpectrumRotation(config);
87
+ var spectrumColor = config_1.getSpectrumColor(config) || image_1.invertColor(defaultColor);
88
+ var spectrumEffect = config_1.getSpectrumEffect(config);
89
+ var spectrumOpacity = config_1.getSpectrumOpacityParsed(config);
90
+ return function (params) {
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 }));
92
+ };
93
+ };
94
+ var preProcessAudio = function (audioBuffer, sampleRate, fps, framesCount) {
95
+ var audioDataStep = Math.trunc(audioBuffer.length / framesCount);
96
+ var processingBuffer = new Float32Array(PROCESSING_BUFFER_SIZE).fill(0);
97
+ var skipFramesCount = fps < 45 ? 1 : 2;
98
+ var processSpectrum = audio_1.createSpectrumsProcessor(sampleRate, skipFramesCount);
99
+ var detectBeat = beats_1.createBeatDetector(fps);
100
+ var spectrums = [];
101
+ var beatFrameIndices = [];
102
+ for (var i = 0; i < framesCount; i++) {
103
+ var currentFrameData = exports.PCM_FORMAT.parseFunction(audioBuffer, i * audioDataStep, i * audioDataStep + audioDataStep);
104
+ processingBuffer.copyWithin(0, currentFrameData.length);
105
+ processingBuffer.set(currentFrameData, PROCESSING_BUFFER_SIZE - currentFrameData.length);
106
+ var audioDataParser = function () { return Array.from(processingBuffer); };
107
+ var spectrum = processSpectrum(audioDataParser);
108
+ var beat = detectBeat(spectrum);
109
+ spectrums.push(spectrum);
110
+ if (beat.isBeat) {
111
+ beatFrameIndices.push(i);
112
+ }
113
+ }
114
+ return { spectrums: spectrums, beatFrameIndices: beatFrameIndices };
115
+ };
116
+ function prepareBackgroundForRender(params) {
117
+ var _a, _b, _c, _d, _e, _f;
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ 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;
120
+ return __generator(this, function (_h) {
121
+ switch (_h.label) {
122
+ case 0:
123
+ useVideoBackground = params.useVideoBackground, backgroundVideoPath = params.backgroundVideoPath, backgroundImagePath = params.backgroundImagePath, beatFrameIndices = params.beatFrameIndices, framesCount = params.framesCount, outputResolution = params.outputResolution, fps = params.fps, autoEditVideo = params.autoEditVideo;
124
+ if (!(useVideoBackground && backgroundVideoPath)) return [3 /*break*/, 6];
125
+ return [4 /*yield*/, video_1.getVideoInfo(backgroundVideoPath)];
126
+ case 1:
127
+ videoInfo = _h.sent();
128
+ if (!autoEditVideo) return [3 /*break*/, 3];
129
+ return [4 /*yield*/, video_1.detectSceneChanges(backgroundVideoPath)];
130
+ case 2:
131
+ _g = _h.sent();
132
+ return [3 /*break*/, 4];
133
+ case 3:
134
+ _g = [];
135
+ _h.label = 4;
136
+ case 4:
137
+ sceneChanges = _g;
138
+ backgroundWidth_1 = (_b = (_a = outputResolution) === null || _a === void 0 ? void 0 : _a.width, (_b !== null && _b !== void 0 ? _b : videoInfo.width));
139
+ backgroundHeight_1 = (_d = (_c = outputResolution) === null || _c === void 0 ? void 0 : _c.height, (_d !== null && _d !== void 0 ? _d : videoInfo.height));
140
+ videoFrameSize = backgroundWidth_1 * backgroundHeight_1 * 3;
141
+ encodeVideoFrame = bpmEncoder_1.createBgrFrameEncoder({ width: backgroundWidth_1, height: backgroundHeight_1 });
142
+ segments = video_1.buildBeatSyncedSegments(beatFrameIndices, framesCount, sceneChanges, videoInfo.duration);
143
+ concatFilePath = video_1.writeConcatFile(segments, backgroundVideoPath, videoInfo.duration, fps);
144
+ videoFrameReader = video_1.spawnConcatVideoFrameReader(__assign({ concatFilePath: concatFilePath,
145
+ fps: fps, totalFrames: framesCount }, (outputResolution && {
146
+ width: backgroundWidth_1,
147
+ height: backgroundHeight_1,
148
+ sourceWidth: videoInfo.width,
149
+ sourceHeight: videoInfo.height,
150
+ })));
151
+ return [4 /*yield*/, video_1.readVideoFrame(videoFrameReader.stdout, videoFrameSize)];
152
+ case 5:
153
+ firstFrame = _h.sent();
154
+ if (!firstFrame) {
155
+ throw new Error("Could not read frames from video: " + backgroundVideoPath);
156
+ }
157
+ defaultColor_1 = image_1.getVideoFrameColor(firstFrame, backgroundWidth_1, backgroundHeight_1);
158
+ staticBackgroundBuffer_1 = encodeVideoFrame(firstFrame);
159
+ return [2 /*return*/, {
160
+ backgroundWidth: backgroundWidth_1,
161
+ backgroundHeight: backgroundHeight_1,
162
+ defaultColor: defaultColor_1,
163
+ staticBackgroundBuffer: staticBackgroundBuffer_1,
164
+ videoFrameReader: videoFrameReader,
165
+ videoFrameSize: videoFrameSize,
166
+ encodeVideoFrame: encodeVideoFrame,
167
+ concatFilePath: concatFilePath,
168
+ }];
169
+ case 6:
170
+ if (!backgroundImagePath) {
171
+ throw new Error('Background image path is required when not using video background.');
172
+ }
173
+ 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)];
174
+ case 7:
175
+ backgroundImageBmpBuffer = _h.sent();
176
+ backgroundImage = image_1.parseImage(backgroundImageBmpBuffer);
177
+ backgroundWidth = backgroundImage.width;
178
+ backgroundHeight = backgroundImage.height;
179
+ defaultColor = image_1.getImageColor(backgroundImage);
180
+ bpmEncoder = bpmEncoder_1.createBpmEncoder({ width: backgroundWidth, height: backgroundHeight });
181
+ staticBackgroundBuffer = bpmEncoder(backgroundImage.data);
182
+ return [2 /*return*/, {
183
+ backgroundWidth: backgroundWidth,
184
+ backgroundHeight: backgroundHeight,
185
+ defaultColor: defaultColor,
186
+ staticBackgroundBuffer: staticBackgroundBuffer,
187
+ videoFrameSize: 0,
188
+ }];
189
+ }
190
+ });
191
+ });
192
+ }
193
+ function resolveBackgroundFrameBuffer(params) {
194
+ return __awaiter(this, void 0, void 0, function () {
195
+ var frameIndex, useVideoBackground, videoFrameReader, videoFrameSize, encodeVideoFrame, staticBackgroundBuffer, videoFrame;
68
196
  return __generator(this, function (_a) {
69
197
  switch (_a.label) {
70
198
  case 0:
199
+ frameIndex = params.frameIndex, useVideoBackground = params.useVideoBackground, videoFrameReader = params.videoFrameReader, videoFrameSize = params.videoFrameSize, encodeVideoFrame = params.encodeVideoFrame, staticBackgroundBuffer = params.staticBackgroundBuffer;
200
+ if (!(useVideoBackground && videoFrameReader && encodeVideoFrame)) return [3 /*break*/, 2];
201
+ if (frameIndex === 0) {
202
+ return [2 /*return*/, staticBackgroundBuffer];
203
+ }
204
+ return [4 /*yield*/, video_1.readVideoFrame(videoFrameReader.stdout, videoFrameSize)];
205
+ case 1:
206
+ videoFrame = _a.sent();
207
+ return [2 /*return*/, videoFrame
208
+ ? encodeVideoFrame(videoFrame)
209
+ : staticBackgroundBuffer];
210
+ case 2: return [2 /*return*/, staticBackgroundBuffer];
211
+ }
212
+ });
213
+ });
214
+ }
215
+ exports.renderAudioVisualizer = function (config, onProgress, shouldStop) {
216
+ return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
217
+ 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;
218
+ return __generator(this, function (_b) {
219
+ switch (_b.label) {
220
+ case 0:
221
+ if (config.outVideo.spectrum && config.outVideo.polar) {
222
+ throw new Error('Cannot use both "spectrum" and "polar" options. Please specify only one visualizer type.');
223
+ }
224
+ if (!config.image && !config.video) {
225
+ throw new Error('Either "image" or "video" must be specified as the background source.');
226
+ }
227
+ if (config.image && config.video) {
228
+ throw new Error('Cannot use both "image" and "video" options. Please specify only one background source.');
229
+ }
71
230
  audioFilePath = config_1.getAudioFilePath(config);
72
- backgroundImagePath = config_1.getBackgroundImagePath(config);
73
231
  outVideoPath = config_1.getOutVideoPath(config);
74
- return [4 /*yield*/, image_1.convertToBmp(backgroundImagePath)];
75
- case 1:
76
- backgroundImageBmpBuffer = _a.sent();
77
- backgroundImage = image_1.parseImage(backgroundImageBmpBuffer);
232
+ backgroundVideoPath = config_1.getBackgroundVideoPath(config);
233
+ backgroundImagePath = config_1.getBackgroundImagePath(config);
234
+ useVideoBackground = !!backgroundVideoPath;
78
235
  return [4 /*yield*/, audio_1.createAudioBuffer(audioFilePath, FFMPEG_FORMAT)];
79
- case 2:
80
- audioReader = _a.sent();
236
+ case 1:
237
+ audioReader = _b.sent();
81
238
  audioBuffer = audioReader.audioBuffer;
82
239
  sampleRate = audioReader.sampleRate;
83
240
  if (!sampleRate) {
@@ -85,68 +242,73 @@ exports.renderAudioVisualizer = function (config, onProgress, shouldStop) {
85
242
  }
86
243
  spectrumBusMargin = config_1.getSpectrumBusMargin();
87
244
  FPS = config_1.getFPS(config);
88
- spectrumWidth = config_1.getSpectrumWidthAbsolute(config, backgroundImage.width);
89
- spectrumHeight = config_1.getSpectrumHeightAbsolute(config, backgroundImage.height);
90
- spectrumX = config_1.getSpectrumXAbsolute(config, spectrumWidth, backgroundImage.width);
91
- spectrumY = config_1.getSpectrumYAbsolute(config, spectrumHeight, backgroundImage.height);
92
- spectrumRotation = config_1.getSpectrumRotation(config);
93
- spectrumColor = config_1.getSpectrumColor(config) ||
94
- image_1.invertColor(image_1.getImageColor(backgroundImage));
95
- spectrumEffect = config_1.getSpectrumEffect(config);
96
- spectrumOpacity = config_1.getSpectrumOpacityParsed(config);
97
245
  ffmpeg_cfr = config_1.getFfmpeg_cfr(config);
98
246
  ffmpeg_preset = config_1.getFfmpeg_preset(config);
99
247
  frame_processing_delay = config_1.getFrame_processing_delay(config);
100
248
  audioDuration = audioBuffer.length / sampleRate;
101
249
  framesCount = Math.trunc(audioDuration * FPS);
102
- audioDataStep = Math.trunc(audioBuffer.length / framesCount);
103
- processingBuffer = new Float32Array(PROCESSING_BUFFER_SIZE).fill(0);
250
+ outputResolution = config_1.getOutputResolution(config);
251
+ preprocessed = preProcessAudio(audioBuffer, sampleRate, FPS, framesCount);
252
+ return [4 /*yield*/, prepareBackgroundForRender({
253
+ useVideoBackground: useVideoBackground,
254
+ backgroundVideoPath: backgroundVideoPath,
255
+ backgroundImagePath: backgroundImagePath,
256
+ beatFrameIndices: preprocessed.beatFrameIndices,
257
+ framesCount: framesCount,
258
+ outputResolution: outputResolution,
259
+ fps: FPS,
260
+ autoEditVideo: config_1.getAutoEditVideo(config),
261
+ })];
262
+ case 2:
263
+ _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;
264
+ createVisualizerFrame = createVisualizerFrameGenerator(config, backgroundWidth, backgroundHeight, defaultColor, spectrumBusMargin);
104
265
  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 })));
105
266
  ffmpegVideoWriter.on('exit', function (code) { return resolve(code); });
106
- bpmEncoder = bpmEncoder_1.createBpmEncoder({ width: backgroundImage.width, height: backgroundImage.height });
107
- backgroundImageBuffer = bpmEncoder(backgroundImage.data);
108
- skipFramesCount = FPS < 45 ? 1 : 2;
109
- processSpectrum = audio_1.createSpectrumsProcessor(sampleRate, skipFramesCount);
110
- createVisualizerFrame = image_1.createVisualizerFrameGenerator();
111
267
  i = 0;
112
- _a.label = 3;
268
+ _b.label = 3;
113
269
  case 3:
114
- if (!(i < framesCount)) return [3 /*break*/, 8];
115
- currentFrameData = exports.PCM_FORMAT.parseFunction(audioBuffer, i * audioDataStep, i * audioDataStep + audioDataStep);
116
- processingBuffer.copyWithin(0, currentFrameData.length);
117
- processingBuffer.set(currentFrameData, PROCESSING_BUFFER_SIZE - currentFrameData.length);
118
- audioDataParser = function () { return Array.from(processingBuffer); };
119
- spectrum = processSpectrum(audioDataParser);
120
- frameImage = createVisualizerFrame({
270
+ if (!(i < framesCount)) return [3 /*break*/, 9];
271
+ spectrum = preprocessed.spectrums[i];
272
+ return [4 /*yield*/, resolveBackgroundFrameBuffer({
273
+ frameIndex: i,
274
+ useVideoBackground: useVideoBackground,
275
+ videoFrameReader: videoFrameReader,
276
+ videoFrameSize: videoFrameSize,
277
+ encodeVideoFrame: encodeVideoFrame,
278
+ staticBackgroundBuffer: staticBackgroundBuffer,
279
+ })];
280
+ case 4:
281
+ backgroundImageBuffer = _b.sent();
282
+ commonVisualizerFrameProps = {
121
283
  backgroundImageBuffer: backgroundImageBuffer,
122
284
  spectrum: spectrum,
123
- size: { width: spectrumWidth, height: spectrumHeight },
124
- position: { x: spectrumX, y: spectrumY },
125
- rotation: spectrumRotation,
126
- margin: spectrumBusMargin,
127
- color: spectrumColor,
128
- opacity: spectrumOpacity,
129
- spectrumEffect: spectrumEffect,
130
- });
285
+ };
286
+ frameImage = createVisualizerFrame(commonVisualizerFrameProps);
131
287
  isFrameProcessed = ffmpegVideoWriter.stdin.write(frameImage.data);
132
- if (!!isFrameProcessed) return [3 /*break*/, 5];
288
+ if (!!isFrameProcessed) return [3 /*break*/, 6];
133
289
  return [4 /*yield*/, video_1.waitDrain(ffmpegVideoWriter.stdin)];
134
- case 4:
135
- _a.sent();
136
- _a.label = 5;
137
290
  case 5:
291
+ _b.sent();
292
+ _b.label = 6;
293
+ case 6:
138
294
  if (shouldStop && shouldStop()) {
139
- return [3 /*break*/, 8];
295
+ return [3 /*break*/, 9];
140
296
  }
141
- if (!frame_processing_delay) return [3 /*break*/, 7];
297
+ if (!frame_processing_delay) return [3 /*break*/, 8];
142
298
  return [4 /*yield*/, sleep(frame_processing_delay)];
143
- case 6:
144
- _a.sent();
145
- _a.label = 7;
146
299
  case 7:
300
+ _b.sent();
301
+ _b.label = 8;
302
+ case 8:
147
303
  i++;
148
304
  return [3 /*break*/, 3];
149
- case 8:
305
+ case 9:
306
+ if (videoFrameReader) {
307
+ videoFrameReader.kill();
308
+ }
309
+ if (concatFilePath) {
310
+ video_1.cleanupConcatFile(concatFilePath);
311
+ }
150
312
  ffmpegVideoWriter.stdin.end();
151
313
  return [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AAC,CAAC,CAAC,CAAC;oBAEb,qBAAM,4BAA4B,CAAC;4BAC/D,UAAU,EAAE,CAAC;4BACb,kBAAkB,oBAAA;4BAClB,gBAAgB,kBAAA;4BAChB,cAAc,gBAAA;4BACd,gBAAgB,kBAAA;4BAChB,sBAAsB,wBAAA;yBACvB,CAAC,EAAA;;oBAPI,qBAAqB,GAAG,SAO5B;oBAEI,0BAA0B,GAA+B;wBAC7D,qBAAqB,uBAAA;wBACrB,QAAQ,UAAA;qBACT,CAAC;oBACI,UAAU,GAAG,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;oBAC/D,gBAAgB,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;yBACpE,CAAC,gBAAgB,EAAjB,wBAAiB;oBACnB,qBAAM,iBAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAA;;oBAAxC,SAAwC,CAAC;;;oBAE3C,IAAI,UAAU,IAAI,UAAU,EAAE,EAAE;wBAC9B,wBAAM;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;AA1GF,CA0GE,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 {};