Skip to main content
Glama

Trim a media file

trim_media_file

Trim a media file on disk between start and end times, creating a new file without altering the source; choose lossless keyframe copy or frame-accurate re-encoding.

Instructions

Write the part of a media file between start and end to a new file. mode "copy" (default) copies the streams without re-encoding: instant and lossless, but video can only start on a keyframe, so the result may begin slightly before start. mode "reencode" is frame accurate and re-encodes (H.264 + AAC for .mp4/.mov/.mkv, the container's default codecs otherwise). Returns the new file's actual duration and streams, and a note when a copy-mode duration differs from the request. This makes a new file on disk and leaves the source unchanged; to trim a clip in a sequence use trim_clip_start / trim_clip_end. Still images cannot be trimmed (BAD_ARGS). Works on the file on disk with ffmpeg, not on the timeline; Premiere Pro is not needed. ffmpeg and ffprobe must be installed (see check_ffmpeg), else FFMPEG_NOT_FOUND.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "output_path": "<output_path>"
    },
    "name": "trim_media_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNoEnd of the part to keep, in file time (seconds); clamped to the file's length. Default: the end of the file.
modeNo"copy" = no re-encoding, cuts on keyframes (default). "reencode" = frame-accurate, slower.
pathYesAbsolute path of the media file on this computer.
startNoStart of the part to keep, in file time (seconds). Default 0.
overwriteNoReplace output_path if it already exists. Default false: an existing file makes the tool fail with FILE_EXISTS.
output_pathYesAbsolute path of the file to write; must differ from path. The extension chooses the container; with mode "copy" keep the source's extension.
timeout_secondsNoStop ffmpeg and fail with TIMEOUT after this many seconds. Default 1800.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the annotations, it discloses the key behavioral traits an agent needs: a new file is created and the source is unchanged, copy mode cuts on keyframes and may begin slightly before start, reencode mode is frame-accurate, return values include actual duration, streams, and a duration-difference note, and specific failure modes include FILE_EXISTS, BAD_ARGS, FFMPEG_NOT_FOUND, and TIMEOUT.

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

Conciseness4/5

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

The description is front-loaded with purpose and mode behavior, then moves to returns, side effects, alternatives, and prerequisites. It is dense and mostly earns its length, though the 'new file on disk / not on the timeline' point is stated more than once, creating slight redundancy.

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

Completeness5/5

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

For a 7-parameter media-writing tool with no output schema, the description covers the critical gaps: it explains return information, source-file safety, mode trade-offs, failure cases, and the ffmpeg dependency. An agent has enough context to invoke it correctly.

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?

Schema coverage is 100%, so the baseline is 3. The description adds meaningful semantics beyond the schema by explaining the practical consequence of copy mode: the result may begin slightly before the requested start because video can only start on a keyframe.

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

Purpose5/5

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

The description uses a specific verb and resource: 'Write the part of a media file between start and end to a new file.' It explicitly distinguishes this disk-file trim from timeline trimming by naming trim_clip_start / trim_clip_end, so an agent can route correctly without opening another schema.

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

Usage Guidelines5/5

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

It gives explicit when-to-use routing: use this tool for a file on disk, and use trim_clip_start / trim_clip_end for a clip in a sequence. It also explains the copy-vs-reencode trade-off, notes that still images cannot be trimmed, and names the check_ffmpeg prerequisite, leaving little to inference.

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

Deploy Server

Other Tools