Skip to main content
Glama

parse_media_info

Extract technical details from media files, including video duration and resolution or image dimensions, to support automated video editing workflows in JianYing.

Instructions

解析媒体文件信息

Args: media_path: 媒体文件路径或URL,支持本地文件和网络URL,不论任何类型的文件都可以,视频可返回时长、分辨率,图片可返回尺寸

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
media_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
messageYes
successYes

Implementation Reference

  • The main MCP tool handler and registration for 'parse_media_info'. It accepts media_path, imports and calls the helper from media_parser.py, constructs a ToolResponse with media information or error.
    @mcp.tool()
    def parse_media_info(media_path: str) -> ToolResponse:
        """
        解析媒体文件信息
        
        Args:
            media_path: 媒体文件路径或URL,支持本地文件和网络URL,不论任何类型的文件都可以,视频可返回时长、分辨率,图片可返回尺寸
        """
        try:
            from jianyingdraft.utils.media_parser import parse_media_info as parse_func
            
            # 调用解析函数
            media_info = parse_func(media_path)
            
            if media_info is None:
                return ToolResponse(
                    success=False,
                    message=f"无法解析媒体文件: {media_path}"
                )
            
            # 构建返回数据
            response_data = {
                "media_path": media_path,
                "media_info": media_info
            }
            
            # 提取关键信息用于消息
            media_type = media_info.get("type", "未知")
            duration = media_info.get("duration")
            resolution = media_info.get("resolution")
            
            message_parts = [f"成功解析 {media_type} 文件"]
            if duration:
                message_parts.append(f"时长: {duration}")
            if resolution:
                message_parts.append(f"分辨率: {resolution}")
            
            return ToolResponse(
                success=True,
                message=", ".join(message_parts),
                data=response_data
            )
            
        except Exception as e:
            return ToolResponse(
                success=False,
                message=f"解析媒体文件失败: {str(e)}"
            )
  • Core parsing method in MediaParser class that dispatches to local or URL parsing using pymediainfo for media info extraction.
    def parse_media_info(self, media_path: str) -> Optional[Dict[str, Any]]:
        """
        解析媒体文件信息
        
        Args:
            media_path: 媒体文件路径或URL
            
        Returns:
            Dict: 媒体信息,包含duration等字段,解析失败返回None
        """
        try:
            if self._is_url(media_path):
                return self._parse_url_media(media_path)
            else:
                return self._parse_local_media(media_path)
        except Exception as e:
            print(f"解析媒体信息失败: {e}")
            return None
  • Convenience helper function imported by the tool handler. Instantiates MediaParser and calls its parse_media_info method, ensuring cleanup.
    def parse_media_info(media_path: str) -> Optional[Dict[str, Any]]:
        """
        解析媒体文件信息的便捷函数
        
        Args:
            media_path: 媒体文件路径或URL
            
        Returns:
            Dict: 媒体信息,解析失败返回None
        """
        parser = MediaParser()
        try:
            return parser.parse_media_info(media_path)
        finally:
            parser.cleanup_all_temp_files()
  • Server registration where utility_tools (containing parse_media_info) is invoked to register the tools with the MCP server.
    from jianyingdraft.tool.utility_tool import utility_tools
    
    
    def main():
        # 注册所有工具
        draft_tools(mcp)
        track_tools(mcp)
        video_tools(mcp)
        text_tools(mcp)
        audio_tools(mcp)
        utility_tools(mcp)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions that the tool returns duration and resolution for videos, and dimensions for images, which gives some behavioral insight. However, it lacks details on error handling, performance characteristics, rate limits, authentication needs, or what happens with unsupported file types. The description is minimal but doesn't contradict any annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief and front-loaded with the main purpose, followed by parameter details. However, the structure is somewhat informal with 'Args:' and mixed language (Chinese and English), and some sentences could be more polished. It avoids unnecessary fluff but could be more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has one parameter with no schema description but an output schema exists, the description provides basic parameter semantics and return value hints. However, as a media parsing tool with no annotations, it lacks details on supported formats, error cases, or integration context. The output schema likely covers return values, but the description doesn't fully address behavioral transparency gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'media_path' can be a local file path or URL, supports any file type, and specifies what information is returned for videos and images. This compensates well for the schema's lack of documentation, though it doesn't detail format constraints or examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '解析媒体文件信息' (parse media file information). It specifies the action (parse) and resource (media files), and distinguishes from sibling tools which are mostly about adding effects, creating drafts, or finding effects. However, it doesn't explicitly differentiate from potential similar tools like 'get_media_metadata' if they existed.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions support for local files and network URLs, but doesn't specify scenarios where this tool is preferred over other media-related tools or what prerequisites might be needed. No explicit when/when-not statements are present.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/hey-jian-wei/jianying-mcp'

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