Clip Videos

View Markdown

You can use the duration, start, and end options to trim your videos and create clips.

This is super useful for creating previews, clips for social media, or capping your users' uploads to a specific duration.


Clip the first 60 seconds

If you only provide a duration option, the video will start at the beginning and end at the specified time.

curl -X POST "https://api.ittybit.com/tasks" \
-H "Authorization: Bearer ITTYBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://ittyb.it/sample.mp4",
  "kind": "video",
  "options": {
    "duration": 60
  }
}'

Clip a specific section

You can combine duration with the start option to clip a specific section of the video. This can be useful if every video has an identical intro that you want to skip before starting your preview clip.

curl -X POST "https://api.ittybit.com/tasks" \
-H "Authorization: Bearer ITTYBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://ittyb.it/sample.mp4",
  "kind": "video",
  "options": {
    "start": 12.34,
    "duration": 60
  }
}'

Clip the last 60 seconds

If you provide only a start option, then the video will start at the specified time and end at the end of the video.

So if you wanted to output the last 60 seconds of each video, then you could use the input file's duration property to calculate the required start value.

curl -X POST "https://api.ittybit.com/tasks" \
-H "Authorization: Bearer ITTYBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://ittyb.it/sample.mp4",
  "kind": "video",
  "options": {
    "start": 240
  }
}'

Set specific start and end times

If you provide both a start and end option, the video will start at the specified time and end at the specified time.

You might combine this with the output from intelligence features like Speech or Outline to create clips based on natural breaks in the content.

curl -X POST "https://api.ittybit.com/tasks" \
-H "Authorization: Bearer ITTYBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://ittyb.it/sample.mp4",
  "kind": "video",
  "options": {
    "start": 12.34,
    "end": 56.78
  }
}'

In the example above, it'd be a good idea to use the filename, folder, and metadata fields to make the clips easily accessible.

const chapters = [
  {
    index: 0,
    start: 12.34,
    end: 56.78,
    text: 'Mr Miyamoto introduces his newest game',
  },
  // ... other chapters
]

const tasks = chapters.map(chapter =>
  fetch('https://api.ittybit.com/tasks', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ITTYBIT_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      url: 'https://ittyb.it/sample.mp4',
      kind: 'video',
      options: {
        start: chapter.start,
        end: chapter.end,
      },
      metadata: {
        ref: `clip-${chapter.index}`,
        index: String(chapter.index),
        description: chapter.text,
      },
    }),
  })
);

On this page