Skip to content

DocsGuides

Trim and clip

Cut a part of a video by start time and length, exact to the frame or at key frames without re-encoding.

trim cuts a part of the input. The input is seeked to the start, so the part before it is not decoded, and only the part you keep is billed as output.

The request#

bash
curl "$VIDEXO_API_URL/v1/transcode" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "https://example.com/talk.mp4",
  "filename": "talk-clip.mp4",
  "trim": {
    "start": "00:01:30",
    "duration": 30
  }
}'

talk-clip.mp4: the 30 seconds that start at 1:30, re-encoded so the cut lands on the exact frame.

trim takes start and either duration or end, as seconds or HH:MM:SS.fraction.

Without re-encoding#

With "codec": "copy" the job is much faster, but the cut lands on the key frame at or before start, as in ffmpeg.

bash
curl "$VIDEXO_API_URL/v1/transcode" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "https://example.com/talk.mp4",
  "filename": "talk-part.mp4",
  "trim": {
    "start": 600,
    "end": 900
  },
  "video": {
    "codec": "copy"
  },
  "audio": {
    "codec": "copy"
  }
}'

Several clips from one input#

Several outputs in one job each read their own part of the same input, which is fetched once.

bash
curl "$VIDEXO_API_URL/v1/jobs" \
  -H "Authorization: Bearer $VIDEXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "talk": "https://example.com/talk.mp4"
  },
  "outputs": [
    {
      "name": "intro",
      "type": "video",
      "trim": {
        "start": 0,
        "duration": 30
      }
    },
    {
      "name": "answer",
      "type": "video",
      "trim": {
        "start": "00:12:05",
        "duration": 45
      }
    }
  ]
}'