Skip to main content
Glama

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
NameRequiredDescriptionDefault
sessionIdYesSession ID from record_page

Implementation Reference

  • 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) };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcpware/pagecast'

If you have feedback or need assistance with the MCP directory API, please join our Discord server