show_video_tool
Extract and save specific video segments by specifying document name and timestamp ranges for focused content retrieval.
Instructions
Creates and saves a video chunk based on the document name, start time, and end time of the chunk.
Returns a message indicating that the video chunk was created successfully.
Args:
document_name (str): The name of the document the chunk belongs to
start_time (float): The start time of the chunk
end_time (float): The end time of the chunk
Returns:
str: A message indicating that the video chunk was created successfully
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_name | Yes | ||
| start_time | Yes | ||
| end_time | Yes |
Implementation Reference
- server.py:45-63 (handler)Handler function for the show_video_tool MCP tool. Registered via @mcp.tool() decorator. Calls the chunk_video helper to create a video clip from the specified document between start_time and end_time, saves it, and returns a success message.@mcp.tool() def show_video_tool(document_name: str, start_time: float, end_time: float) -> str: """ Creates and saves a video chunk based on the document name, start time, and end time of the chunk. Returns a message indicating that the video chunk was created successfully. Args: document_name (str): The name of the document the chunk belongs to start_time (float): The start time of the chunk end_time (float): The end time of the chunk Returns: str: A message indicating that the video chunk was created successfully """ try: chunk_video(document_name, start_time, end_time) return "Video chunk created successfully" except Exception as e: return f"Failed to create video chunk: {str(e)}"
- main.py:111-126 (helper)Supporting helper function that implements the core video chunking logic using moviepy.VideoFileClip. Loads video from 'videos/{document_name}', extracts subclip from start_time to end_time (clamped to duration), saves as mp4 in 'video_chunks/' directory.def chunk_video(document_name, start_time, end_time, directory="videos"): # Create output filename output_dir = Path("video_chunks") output_dir.mkdir(parents=True, exist_ok=True) chunk_filename = f"video_chunk_{start_time:.1f}_{end_time:.1f}.mp4" output_path = output_dir / chunk_filename with VideoFileClip(directory + "/" + document_name) as video: video_duration = video.duration actual_end_time = min(end_time, video_duration) if end_time is not None else video_duration video_chunk = video.subclipped(start_time, actual_end_time) video_chunk.write_videofile(str(output_path)) return output_path