stop_recording
Stop a browser page recording session and save the video as a .webm file using the session ID from record_page.
Instructions
Stop a recording session and save the video as .webm file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID from record_page |
Implementation Reference
- src/recorder.js:126-144 (handler)The implementation of `stopRecording` function that flushes the video, closes the context, and renames the file.
export async function stopRecording(sessionId) { const session = sessions.get(sessionId); if (!session) throw new Error(`Session ${sessionId} not found. Active sessions: ${[...sessions.keys()].join(', ') || 'none'}`); // Get the auto-generated video path before closing const videoPath = await session.page.video().path(); // Close context — this finalizes the video file await session.context.close(); // Rename to predictable name const finalPath = join(session.outputDir, `recording-${sessionId}.webm`); await rename(videoPath, finalPath); const duration = ((Date.now() - new Date(session.startedAt).getTime()) / 1000).toFixed(1); sessions.delete(sessionId); return { webmPath: finalPath, durationSeconds: parseFloat(duration) }; }