Segment videos
This quickstart guide provides a simplified introduction to segmenting videos into structured, timestamped data using the TwelveLabs Video Understanding Platform. It includes the following:
- A basic working example
- Minimal implementation details
- Core parameters for common use cases
For a comprehensive guide, see the Segment videos guide.
Key concepts
This section explains the key concepts and terminology used in this guide:
- Asset: Your uploaded content. Once created, you can reference the same asset across multiple operations without uploading the file again.
- Segment definition: A description of a type of segment you want to extract. Each definition includes a unique identifier, a natural language description, and optional custom fields.
- Segment field: A custom metadata field to extract for each segment. Each field has a name, a type, and a description.
Workflow
This guide shows how to upload your video as an asset, create an asynchronous segmentation task with Pegasus 1.5, and parse the timestamped metadata from the results.
Prerequisites
-
To use the platform, you need an API key:
-
Depending on the programming language you are using, install the TwelveLabs SDK by entering one of the following commands:
-
Your video files must meet the following requirements:
-
Upload limits: Public video URLs up to 2 GB or local video files up to 200 MB. For local files up to 2 GB, see the Upload and processing methods page.
-
Analysis method: Videos up to 2 hours.
-
Model capabilities: See the complete requirements for video files
-
Starter code
Copy and paste the code below, replacing the placeholders surrounded by <> with your values. The example defines a single segment type (scenes) with three custom fields to illustrate the shape. Adapt the segment definitions to match what you want to extract from your videos.
Code explanation
Import the SDK and initialize the client
Create a client instance to interact with the TwelveLabs Video Understanding Platform.
Check the status of the asset
You only need this step for URL uploads larger than 200 MB. The platform processes these files asynchronously.