getVideoInfo
Extract detailed metadata from video files, including resolution, duration, and format, to streamline video analysis and processing workflows.
Instructions
获取视频文件的详细信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | 视频文件路径 |
Implementation Reference
- src/mcp/server.ts:380-390 (handler)MCP tool handler for 'getVideoInfo' that delegates to VideoEngine.getVideoInfo and returns the result formatted as MCP response content.private async handleGetVideoInfo(args: MCPToolParams['getVideoInfo']) { const result = await this.videoEngine.getVideoInfo(args.filePath); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/core/video-engine.ts:43-71 (helper)Core implementation of getVideoInfo in VideoEngine using ffmpeg.ffprobe to extract comprehensive video metadata including duration, dimensions, FPS, bitrate, format, codec, and file size.public async getVideoInfo(filePath: string): Promise<VideoInfo> { return new Promise((resolve, reject) => { ffmpeg.ffprobe(filePath, (err: any, metadata: any) => { if (err) { reject(new Error(`获取视频信息失败: ${err.message}`)); return; } const videoStream = metadata.streams.find((s: any) => s.codec_type === 'video'); if (!videoStream) { reject(new Error('未找到视频流')); return; } const audioStream = metadata.streams.find((s: any) => s.codec_type === 'audio'); resolve({ duration: metadata.format.duration || 0, width: videoStream.width || 0, height: videoStream.height || 0, fps: this.parseFps(videoStream.r_frame_rate || '0/1'), bitrate: parseInt(metadata.format.bit_rate || '0'), format: metadata.format.format_name || '', codec: videoStream.codec_name || '', size: parseInt(metadata.format.size || '0') }); }); }); }
- src/mcp/server.ts:260-273 (registration)Registration of the 'getVideoInfo' tool in the MCP server's list of tools, defining its name, description, and input schema.{ name: 'getVideoInfo', description: '获取视频文件的详细信息', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: '视频文件路径' } }, required: ['filePath'] } },
- src/types/mcp.ts:26-55 (schema)TypeScript type definitions for getVideoInfo input parameters (MCPToolParams) and output (MCPToolResults).getVideoInfo: { filePath: string; }; // 批量处理工具参数 batchProcess: { tasks: Omit<BatchTask, 'id' | 'status' | 'createdAt'>[]; }; // 获取支持格式工具参数 getSupportedFormats: Record<string, never>; // 取消任务工具参数 cancelTask: { taskId: string; }; // 获取任务状态工具参数 getTaskStatus: { taskId: string; }; } // MCP工具返回值类型 export interface MCPToolResults { clipVideo: ProcessResult; mergeVideos: ProcessResult; splitVideo: ProcessResult; getVideoInfo: VideoInfo; batchProcess: {