getVideoInfo
Extract video metadata like duration, resolution, and format details from files to analyze content properties and verify specifications.
Instructions
获取视频文件的详细信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | 视频文件路径 |
Implementation Reference
- src/mcp/server.ts:380-390 (handler)MCP tool handler that receives arguments, calls VideoEngine.getVideoInfo, and returns the result as a formatted text response.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 using FFprobe to extract comprehensive video metadata including duration, dimensions, FPS, bitrate, container format, video 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)Tool registration definition including name, description, and JSON input schema requiring 'filePath'.{ name: 'getVideoInfo', description: '获取视频文件的详细信息', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: '视频文件路径' } }, required: ['filePath'] } },
- src/types/mcp.ts:26-28 (schema)TypeScript type definition for getVideoInfo input parameters.getVideoInfo: { filePath: string; };
- src/types/mcp.ts:54-54 (schema)TypeScript type definition for getVideoInfo output returning VideoInfo.getVideoInfo: VideoInfo;