trim_clip
Modify the start and end points of a clip in Adobe Premiere Pro to adjust its length directly through automation, using clip ID and precise timing inputs.
Instructions
Adjusts the in and out points of a clip on the timeline, effectively shortening it.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clipId | Yes | The ID of the clip on the timeline to trim | |
| duration | No | Alternative: set the desired duration in seconds | |
| inPoint | No | The new in point in seconds from the start of the clip | |
| outPoint | No | The new out point in seconds from the start of the clip |
Implementation Reference
- src/tools/index.ts:1111-1151 (handler)The handler function for trim_clip. It constructs and executes an ExtendScript that finds the clip by ID and adjusts its inPoint, outPoint, or sets a new duration by modifying outPoint accordingly. Returns old and new points for verification.private async trimClip(clipId: string, inPoint?: number, outPoint?: number, duration?: number): Promise<any> { const script = ` try { var clip = app.project.getClipByID("${clipId}"); if (!clip) { JSON.stringify({ success: false, error: "Clip not found" }); return; } var oldInPoint = clip.inPoint.seconds; var oldOutPoint = clip.outPoint.seconds; var oldDuration = clip.duration.seconds; ${inPoint !== undefined ? `clip.inPoint = new Time("${inPoint}s");` : ''} ${outPoint !== undefined ? `clip.outPoint = new Time("${outPoint}s");` : ''} ${duration !== undefined ? `clip.outPoint = new Time(clip.inPoint.seconds + ${duration});` : ''} JSON.stringify({ success: true, message: "Clip trimmed successfully", clipId: "${clipId}", oldInPoint: oldInPoint, oldOutPoint: oldOutPoint, oldDuration: oldDuration, newInPoint: clip.inPoint.seconds, newOutPoint: clip.outPoint.seconds, newDuration: clip.duration.seconds }); } catch (e) { JSON.stringify({ success: false, error: e.toString() }); } `; return await this.bridge.executeScript(script); }
- src/tools/index.ts:172-179 (schema)Input schema validation using Zod for the trim_clip tool parameters.name: 'trim_clip', description: 'Adjusts the in and out points of a clip on the timeline, effectively shortening it.', inputSchema: z.object({ clipId: z.string().describe('The ID of the clip on the timeline to trim'), inPoint: z.number().optional().describe('The new in point in seconds from the start of the clip'), outPoint: z.number().optional().describe('The new out point in seconds from the start of the clip'), duration: z.number().optional().describe('Alternative: set the desired duration in seconds') })
- src/tools/index.ts:468-469 (registration)Dispatches to the trimClip handler method in the executeTool switch statement.case 'trim_clip': return await this.trimClip(args.clipId, args.inPoint, args.outPoint, args.duration);