@t3lnet/sceneforge 1.0.26 → 1.0.27
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.
|
@@ -292,8 +292,9 @@ export async function runRecordDemoCommand(argv) {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
// Stop CDP recorder before closing context
|
|
295
|
+
let cdpStopInfo = null;
|
|
295
296
|
if (cdpRecorder) {
|
|
296
|
-
await cdpRecorder.stop();
|
|
297
|
+
cdpStopInfo = await cdpRecorder.stop();
|
|
297
298
|
}
|
|
298
299
|
|
|
299
300
|
await context.close();
|
|
@@ -307,7 +308,9 @@ export async function runRecordDemoCommand(argv) {
|
|
|
307
308
|
await cdpRecorder.assembleVideo(finalVideoPath, { fps: hqFps });
|
|
308
309
|
console.log(`[record] High-quality video saved: ${finalVideoPath}`);
|
|
309
310
|
if (result.scriptPath) {
|
|
310
|
-
|
|
311
|
+
// Use the actual first frame time for alignment, not when we started the recorder
|
|
312
|
+
const actualVideoStartTime = cdpStopInfo?.firstFrameTime || videoRecordingStartTime;
|
|
313
|
+
await alignScriptToVideo(result.scriptPath, finalVideoPath, actualVideoStartTime);
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
} finally {
|
|
@@ -55,6 +55,7 @@ export function createCDPRecorder(page, options) {
|
|
|
55
55
|
let frameTimestamps = [];
|
|
56
56
|
let isRecording = false;
|
|
57
57
|
let startTime = null;
|
|
58
|
+
let firstFrameTime = null; // Wall clock time when first frame was received
|
|
58
59
|
let writeQueue = Promise.resolve();
|
|
59
60
|
let nextFrameNumber = 0;
|
|
60
61
|
|
|
@@ -64,6 +65,11 @@ export function createCDPRecorder(page, options) {
|
|
|
64
65
|
const { data, metadata, sessionId } = params;
|
|
65
66
|
frameCount += 1;
|
|
66
67
|
|
|
68
|
+
// Track when we receive the first frame (wall clock time)
|
|
69
|
+
if (firstFrameTime === null) {
|
|
70
|
+
firstFrameTime = Date.now();
|
|
71
|
+
}
|
|
72
|
+
|
|
67
73
|
// Acknowledge the frame immediately to continue receiving
|
|
68
74
|
cdpSession.send("Page.screencastFrameAck", { sessionId }).catch(() => {
|
|
69
75
|
// Session may be closed
|
|
@@ -156,15 +162,21 @@ export function createCDPRecorder(page, options) {
|
|
|
156
162
|
// Wait for all pending frame writes to complete
|
|
157
163
|
await writeQueue;
|
|
158
164
|
|
|
165
|
+
const delayToFirstFrame = firstFrameTime ? firstFrameTime - startTime : 0;
|
|
159
166
|
console.log(
|
|
160
167
|
`[cdp-recorder] Captured ${frameTimestamps.length} frames in ${(duration / 1000).toFixed(2)}s`
|
|
161
168
|
);
|
|
169
|
+
if (delayToFirstFrame > 100) {
|
|
170
|
+
console.log(`[cdp-recorder] First frame delay: ${delayToFirstFrame}ms`);
|
|
171
|
+
}
|
|
162
172
|
|
|
163
173
|
return {
|
|
164
174
|
frameCount: frameTimestamps.length,
|
|
165
175
|
duration,
|
|
166
176
|
framesDir,
|
|
167
177
|
frameTimestamps,
|
|
178
|
+
firstFrameTime, // Wall clock time when first frame was captured
|
|
179
|
+
startTime, // Wall clock time when recording was started
|
|
168
180
|
};
|
|
169
181
|
},
|
|
170
182
|
|