Trim a media file
trim_media_fileTrim 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
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | End of the part to keep, in file time (seconds); clamped to the file's length. Default: the end of the file. | |
| mode | No | "copy" = no re-encoding, cuts on keyframes (default). "reencode" = frame-accurate, slower. | |
| path | Yes | Absolute path of the media file on this computer. | |
| start | No | Start of the part to keep, in file time (seconds). Default 0. | |
| overwrite | No | Replace output_path if it already exists. Default false: an existing file makes the tool fail with FILE_EXISTS. | |
| output_path | Yes | Absolute path of the file to write; must differ from path. The extension chooses the container; with mode "copy" keep the source's extension. | |
| timeout_seconds | No | Stop ffmpeg and fail with TIMEOUT after this many seconds. Default 1800. |