@meframe/core 0.5.10 → 0.5.12
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/model/types.d.ts +11 -7
- package/dist/model/types.d.ts.map +1 -1
- package/dist/model/types.js.map +1 -1
- package/dist/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js.map +1 -0
- package/dist/{meframe-service/node_modules → node_modules}/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js +14 -14
- package/dist/node_modules/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js.map +1 -0
- package/dist/stages/compose/OfflineAudioMixer.d.ts.map +1 -1
- package/dist/stages/compose/OfflineAudioMixer.js +64 -5
- package/dist/stages/compose/OfflineAudioMixer.js.map +1 -1
- package/dist/stages/compose/VideoComposer.d.ts +9 -0
- package/dist/stages/compose/VideoComposer.d.ts.map +1 -1
- package/dist/stages/compose/VideoComposer.js +15 -0
- package/dist/stages/compose/VideoComposer.js.map +1 -1
- package/dist/stages/encode/AudioChunkEncoder.d.ts +1 -0
- package/dist/stages/encode/AudioChunkEncoder.d.ts.map +1 -1
- package/dist/stages/encode/AudioChunkEncoder.js +4 -1
- package/dist/stages/encode/AudioChunkEncoder.js.map +1 -1
- package/dist/stages/encode/BaseEncoder.d.ts +12 -0
- package/dist/stages/encode/BaseEncoder.d.ts.map +1 -1
- package/dist/stages/encode/BaseEncoder.js +28 -0
- package/dist/stages/encode/BaseEncoder.js.map +1 -1
- package/dist/stages/encode/VideoChunkEncoder.d.ts +1 -0
- package/dist/stages/encode/VideoChunkEncoder.d.ts.map +1 -1
- package/dist/stages/mux/MP4Muxer.js +1 -1
- package/dist/utils/mp4box.js +1 -1
- package/dist/workers/stages/export/{export.worker.XX9XDu3o.js → export.worker.CO7nW1W0.js} +58 -2
- package/dist/workers/stages/export/export.worker.CO7nW1W0.js.map +1 -0
- package/dist/workers/worker-manifest.json +1 -1
- package/package.json +1 -1
- package/dist/meframe-service/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js.map +0 -1
- package/dist/meframe-service/node_modules/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js.map +0 -1
- package/dist/workers/stages/export/export.worker.XX9XDu3o.js.map +0 -1
- /package/dist/{meframe-service/node_modules → node_modules}/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js +0 -0
|
@@ -2268,6 +2268,9 @@ class VideoComposer {
|
|
|
2268
2268
|
fontsLoadingPromise = null;
|
|
2269
2269
|
loadedFonts = /* @__PURE__ */ new Set();
|
|
2270
2270
|
static FONT_LOAD_TIMEOUT_MS = 1e4;
|
|
2271
|
+
// 导出耗时埋点:累计合成(含字幕逐帧绘制)耗时与帧数,由 export.worker 在 flush 时汇总打印。
|
|
2272
|
+
traceComposeMs = 0;
|
|
2273
|
+
traceComposeFrames = 0;
|
|
2271
2274
|
constructor(config) {
|
|
2272
2275
|
this.config = this.applyDefaults(config);
|
|
2273
2276
|
this.frameDurationUs = Math.round(1e6 / this.config.fps);
|
|
@@ -2335,7 +2338,10 @@ class VideoComposer {
|
|
|
2335
2338
|
const stream = new TransformStream(
|
|
2336
2339
|
{
|
|
2337
2340
|
transform: async (request, controller) => {
|
|
2341
|
+
const t0 = performance.now();
|
|
2338
2342
|
const result = await this.composeFrame(request);
|
|
2343
|
+
this.traceComposeMs += performance.now() - t0;
|
|
2344
|
+
this.traceComposeFrames++;
|
|
2339
2345
|
if (result.frame) {
|
|
2340
2346
|
controller.enqueue(result.frame);
|
|
2341
2347
|
}
|
|
@@ -2355,6 +2361,15 @@ class VideoComposer {
|
|
|
2355
2361
|
);
|
|
2356
2362
|
return stream;
|
|
2357
2363
|
}
|
|
2364
|
+
/** 重置合成耗时埋点(每次导出开始时由 export.worker 调用)。 */
|
|
2365
|
+
resetTraceStats() {
|
|
2366
|
+
this.traceComposeMs = 0;
|
|
2367
|
+
this.traceComposeFrames = 0;
|
|
2368
|
+
}
|
|
2369
|
+
/** 读取累计合成耗时埋点(导出结束时由 export.worker 汇总)。 */
|
|
2370
|
+
getTraceStats() {
|
|
2371
|
+
return { composeMs: this.traceComposeMs, composeFrames: this.traceComposeFrames };
|
|
2372
|
+
}
|
|
2358
2373
|
async composeFrame(request) {
|
|
2359
2374
|
if (this.fontsLoadingPromise) {
|
|
2360
2375
|
try {
|
|
@@ -2530,6 +2545,10 @@ class BaseEncoder {
|
|
|
2530
2545
|
encoder;
|
|
2531
2546
|
config;
|
|
2532
2547
|
controller = null;
|
|
2548
|
+
// 导出耗时埋点:WebCodecs encode() 异步非阻塞,编码真实开销体现在「背压等待」与「flush 排空」。
|
|
2549
|
+
traceBackpressureMs = 0;
|
|
2550
|
+
traceFlushMs = 0;
|
|
2551
|
+
traceFrames = 0;
|
|
2533
2552
|
constructor(config) {
|
|
2534
2553
|
this.config = config;
|
|
2535
2554
|
}
|
|
@@ -2577,6 +2596,11 @@ class BaseEncoder {
|
|
|
2577
2596
|
console.warn("Codec not supported:", JSON.stringify(this.config));
|
|
2578
2597
|
throw new Error(`Codec not supported: ${JSON.stringify(this.config)}`);
|
|
2579
2598
|
}
|
|
2599
|
+
const req = this.config;
|
|
2600
|
+
const resolvedCfg = isSupported.config ?? this.config;
|
|
2601
|
+
console.info(
|
|
2602
|
+
`[Encoder] [trace:total] configured codec=${resolvedCfg.codec ?? req.codec} requestedHardwareAcceleration=${req.hardwareAcceleration ?? "no-preference"} resolvedHardwareAcceleration=${resolvedCfg.hardwareAcceleration ?? "unknown"} bitrate=${req.bitrate ?? "default"} ${req.width ?? "?"}x${req.height ?? "?"}`
|
|
2603
|
+
);
|
|
2580
2604
|
this.encoder = this.createEncoder({
|
|
2581
2605
|
output: this.handleOutput.bind(this),
|
|
2582
2606
|
error: this.handleError.bind(this)
|
|
@@ -2688,6 +2712,7 @@ class BaseEncoder {
|
|
|
2688
2712
|
await this.initialize();
|
|
2689
2713
|
}
|
|
2690
2714
|
if (this.encoder && this.encoder.encodeQueueSize >= this.encodeQueueThreshold) {
|
|
2715
|
+
const bp0 = performance.now();
|
|
2691
2716
|
await new Promise((resolve) => {
|
|
2692
2717
|
const check = () => {
|
|
2693
2718
|
if (!this.encoder || this.encoder.encodeQueueSize < this.encodeQueueThreshold - 1) {
|
|
@@ -2698,6 +2723,7 @@ class BaseEncoder {
|
|
|
2698
2723
|
};
|
|
2699
2724
|
check();
|
|
2700
2725
|
});
|
|
2726
|
+
this.traceBackpressureMs += performance.now() - bp0;
|
|
2701
2727
|
}
|
|
2702
2728
|
if (!this.isReady) {
|
|
2703
2729
|
console.warn("Encoder is not ready, initializing 2...");
|
|
@@ -2709,9 +2735,12 @@ class BaseEncoder {
|
|
|
2709
2735
|
}
|
|
2710
2736
|
const frame = input.frame || input;
|
|
2711
2737
|
this.encode(frame);
|
|
2738
|
+
this.traceFrames++;
|
|
2712
2739
|
},
|
|
2713
2740
|
flush: async () => {
|
|
2741
|
+
const flush0 = performance.now();
|
|
2714
2742
|
await this.flush();
|
|
2743
|
+
this.traceFlushMs += performance.now() - flush0;
|
|
2715
2744
|
}
|
|
2716
2745
|
},
|
|
2717
2746
|
// Queuing strategy with backpressure configuration
|
|
@@ -2722,6 +2751,20 @@ class BaseEncoder {
|
|
|
2722
2751
|
}
|
|
2723
2752
|
);
|
|
2724
2753
|
}
|
|
2754
|
+
/** 重置编码耗时埋点(每次导出开始时由 export.worker 调用)。 */
|
|
2755
|
+
resetTraceStats() {
|
|
2756
|
+
this.traceBackpressureMs = 0;
|
|
2757
|
+
this.traceFlushMs = 0;
|
|
2758
|
+
this.traceFrames = 0;
|
|
2759
|
+
}
|
|
2760
|
+
/** 读取累计编码耗时埋点(导出结束时由 export.worker 汇总)。 */
|
|
2761
|
+
getTraceStats() {
|
|
2762
|
+
return {
|
|
2763
|
+
backpressureMs: this.traceBackpressureMs,
|
|
2764
|
+
flushMs: this.traceFlushMs,
|
|
2765
|
+
frames: this.traceFrames
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2725
2768
|
}
|
|
2726
2769
|
class VideoChunkEncoder extends BaseEncoder {
|
|
2727
2770
|
static DEFAULT_HIGH_WATER_MARK = 2;
|
|
@@ -2749,7 +2792,10 @@ class VideoChunkEncoder extends BaseEncoder {
|
|
|
2749
2792
|
}
|
|
2750
2793
|
async isConfigSupported(config) {
|
|
2751
2794
|
const result = await VideoEncoder.isConfigSupported(config);
|
|
2752
|
-
return {
|
|
2795
|
+
return {
|
|
2796
|
+
supported: result.supported ?? false,
|
|
2797
|
+
config: result.config
|
|
2798
|
+
};
|
|
2753
2799
|
}
|
|
2754
2800
|
createEncoder(init) {
|
|
2755
2801
|
return new VideoEncoder(init);
|
|
@@ -3297,6 +3343,8 @@ class ExportWorker {
|
|
|
3297
3343
|
this.composer = new VideoComposer(compose);
|
|
3298
3344
|
this.encoder = new VideoChunkEncoder(encode);
|
|
3299
3345
|
await this.encoder.initialize();
|
|
3346
|
+
this.composer.resetTraceStats();
|
|
3347
|
+
this.encoder.resetTraceStats();
|
|
3300
3348
|
this.channel.state = WorkerState.Ready;
|
|
3301
3349
|
return { success: true };
|
|
3302
3350
|
}
|
|
@@ -3435,6 +3483,14 @@ class ExportWorker {
|
|
|
3435
3483
|
if (this.encoder) {
|
|
3436
3484
|
await this.encoder.flush();
|
|
3437
3485
|
}
|
|
3486
|
+
if (this.composer && this.encoder) {
|
|
3487
|
+
const c = this.composer.getTraceStats();
|
|
3488
|
+
const e = this.encoder.getTraceStats();
|
|
3489
|
+
const msPerFrame = c.composeFrames > 0 ? (c.composeMs / c.composeFrames).toFixed(1) : "0";
|
|
3490
|
+
console.info(
|
|
3491
|
+
`[ExportWorker] [trace:total] compose ${(c.composeMs / 1e3).toFixed(2)}s (${c.composeFrames}f, ${msPerFrame}ms/f) | encode ${e.frames}f backpressure ${(e.backpressureMs / 1e3).toFixed(2)}s flush-drain ${(e.flushMs / 1e3).toFixed(2)}s`
|
|
3492
|
+
);
|
|
3493
|
+
}
|
|
3438
3494
|
return { success: true };
|
|
3439
3495
|
}
|
|
3440
3496
|
async handleDispose() {
|
|
@@ -3500,4 +3556,4 @@ const export_worker = null;
|
|
|
3500
3556
|
export {
|
|
3501
3557
|
export_worker as default
|
|
3502
3558
|
};
|
|
3503
|
-
//# sourceMappingURL=export.worker.
|
|
3559
|
+
//# sourceMappingURL=export.worker.CO7nW1W0.js.map
|