/** * Video streaming and encoding types for bot-spawner * * This module defines types for video frame processing and encoding operations. * These types are designed to be flexible and work with multiple encoding approaches. */ /** * Represents a single video frame with image data */ export interface VideoFrame { /** Frame data as Buffer (PNG, JPEG, or raw pixel data) */ data: Buffer; /** Width of the frame in pixels */ width: number; /** Height of the frame in pixels */ height: number; /** Frame timestamp in milliseconds from start */ timestamp: number; /** Format of the frame data (e.g., 'png', 'jpeg', 'rgba') */ format: 'png' | 'jpeg' | 'rgba' | 'rgb'; } /** * Configuration options for video encoding */ export interface VideoEncodingOptions { /** Output video width in pixels */ width: number; /** Output video height in pixels */ height: number; /** Frame rate (frames per second) */ frameRate: number; /** Video codec to use (e.g., 'libx264', 'vp8', 'vp9') */ codec?: string; /** Video bitrate in bits per second */ bitrate?: number; /** Pixel format (e.g., 'yuv420p') */ pixelFormat?: string; /** Output format (e.g., 'mp4', 'webm') */ outputFormat?: 'mp4' | 'webm'; /** Enable constant rate factor (CRF) mode for quality-based encoding */ crf?: number; /** Preset for encoding speed vs compression (e.g., 'ultrafast', 'fast', 'medium', 'slow') */ preset?: string; } /** * Result of a video encoding operation */ export interface VideoEncodingResult { /** Encoded video data as Buffer */ data: Buffer; /** Format of the encoded video */ format: string; /** Duration of the video in milliseconds */ duration: number; /** Size of the encoded video in bytes */ size: number; /** Number of frames encoded */ frameCount: number; } /** * Metadata about a video stream */ export interface VideoStreamMetadata { /** Unique identifier for the stream */ streamId: string; /** Width of the video in pixels */ width: number; /** Height of the video in pixels */ height: number; /** Frame rate (frames per second) */ frameRate: number; /** Start time of the stream */ startTime: Date; /** End time of the stream (if completed) */ endTime?: Date; /** Total number of frames captured */ frameCount: number; /** Duration in milliseconds */ duration: number; } /** * Options for frame capture/processing */ export interface FrameCaptureOptions { /** Maximum number of frames to capture */ maxFrames?: number; /** Interval between frame captures in milliseconds */ captureInterval?: number; /** Whether to compress frames before storage */ compress?: boolean; /** Quality setting for compression (0-100) */ quality?: number; /** Target width for frame resizing (maintains aspect ratio if only width provided) */ targetWidth?: number; /** Target height for frame resizing (maintains aspect ratio if only height provided) */ targetHeight?: number; } /** * Status of a video encoding operation */ export type EncodingStatus = | 'pending' | 'encoding' | 'completed' | 'failed'; /** * Progress information for video encoding */ export interface EncodingProgress { /** Current status */ status: EncodingStatus; /** Number of frames processed so far */ framesProcessed: number; /** Total number of frames to process */ totalFrames: number; /** Progress percentage (0-100) */ percentage: number; /** Error message if status is 'failed' */ error?: string; /** Estimated time remaining in milliseconds */ estimatedTimeRemaining?: number; } /** * Bot configuration */ export interface BotConfig { /** Unique bot identifier */ botId: string; /** Session ID this bot belongs to */ sessionId: string; /** LiveKit room name */ roomName: string; /** LiveKit server URL */ livekitUrl: string; /** Token for screenshare bot participant */ screenshareToken: string; /** URL of the Slidev deck to display */ deckUrl: string; } /** * Bot status information */ export interface BotStatus { /** Bot identifier */ botId: string; /** Current status */ status: 'spawning' | 'running' | 'stopping' | 'stopped' | 'error'; /** Room name */ roomName: string; /** Session ID */ sessionId: string; /** Creation timestamp */ createdAt: string; } /** * Slide control command */ export interface SlideCommand { /** Command action */ action: 'next' | 'prev' | 'goto'; /** Target slide number (for goto action) */ slide_number?: number; } /** * Request payload for spawning a bot */ export interface SpawnBotRequest { /** LiveKit room name */ room_name: string; /** URL of the Slidev deck to display */ deck_url: string; /** Session ID for the bot */ session_id: string; /** Token for screenshare bot participant */ screenshare_token: string; } /** * Response from spawning a bot */ export interface SpawnBotResponse { /** Generated bot ID */ bot_id: string; /** Current bot status */ status: string; /** LiveKit room name */ room_name?: string; /** Estimated time for bot to join room */ estimated_join_time?: string; /** Success/error message */ message?: string; /** Error details if spawn failed */ error?: string; /** Additional error details */ details?: string; }