Trim / Clip
The trim recipe cuts a segment from your media at a specified start time and duration. Use it to extract highlights, remove intros, or clip a specific scene.
Basic usage
Section titled “Basic usage”Extract 30 seconds starting at the 1-minute mark:
curl -X POST https://api.xora.sh/v1/jobs \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mode": "recipe", "input": { "url": "https://example.com/long-video.mp4" }, "output": { "format": "mp4" }, "recipe": { "name": "trim", "startSeconds": 60, "durationSeconds": 30 } }'const response = await fetch('https://api.xora.sh/v1/jobs', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ mode: 'recipe', input: { url: 'https://example.com/long-video.mp4' }, output: { format: 'mp4' }, recipe: { name: 'trim', startSeconds: 60, durationSeconds: 30 } })});const data = await response.json();console.log(data);import requests
response = requests.post( "https://api.xora.sh/v1/jobs", headers={ "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" }, json={ "mode": "recipe", "input": { "url": "https://example.com/long-video.mp4" }, "output": { "format": "mp4" }, "recipe": { "name": "trim", "startSeconds": 60, "durationSeconds": 30 } })data = response.json()print(data)Response
Section titled “Response”{ "jobId": "01JXYZ1234ABCDEF56789000", "state": "queued"}Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Must be "trim" |
startSeconds | number | No | Start time in seconds (default: 0) |
durationSeconds | number | No | Duration of the clip in seconds |
Examples
Section titled “Examples”Extract the first 10 seconds
Section titled “Extract the first 10 seconds”{ "mode": "recipe", "input": { "url": "https://example.com/video.mp4" }, "output": { "format": "mp4" }, "recipe": { "name": "trim", "durationSeconds": 10 }}Skip the first 5 seconds (remove intro)
Section titled “Skip the first 5 seconds (remove intro)”{ "mode": "recipe", "input": { "url": "https://example.com/video.mp4" }, "output": { "format": "mp4" }, "recipe": { "name": "trim", "startSeconds": 5 }}This produces a clip from 5 seconds to the end of the video.
Extract a highlight from the middle
Section titled “Extract a highlight from the middle”{ "mode": "recipe", "input": { "url": "https://example.com/webinar.mp4" }, "output": { "format": "mp4" }, "recipe": { "name": "trim", "startSeconds": 300, "durationSeconds": 120 }}Extracts a 2-minute clip starting at the 5-minute mark.
Trim audio
Section titled “Trim audio”Trimming works on audio files too:
{ "mode": "recipe", "input": { "url": "https://example.com/podcast.mp3" }, "output": { "format": "mp3" }, "recipe": { "name": "trim", "startSeconds": 0, "durationSeconds": 60 }}Supported output formats
Section titled “Supported output formats”| Format | Type |
|---|---|
mp4 | Video |
webm | Video |
mov | Video |
mp3 | Audio |
aac | Audio |
wav | Audio |