3. Transfer and index videos

This section shows how to transfer the files from your AWS S3 bucket to Twelve Labs and index them.

๐Ÿ“˜

Note

The platform checks for duplicate files using hashes and will not upload the same video to the same index twice.

Prerequisites

Procedure

  1. Import the required packages into your application:
    from twelvelabs import TwelveLabs
    from twelvelabs.models.task import Task
    
    import { TwelveLabs, Task } from 'twelvelabs-js';
    import * as fs from 'fs';
    
  2. Instantiate the SDK client with your API key:
    client = TwelveLabs(api_key="<YOUR_API_KEY>")
    
    const client = new TwelveLabs({ apiKey: '<YOUR_API_KEY>' });
    
  3. To perform a cloud-to-cloud transfer, invoke the transfer method of the task object, passing it a string representing the path to your JSON file as a parameter:
    client.task.transfer(file="<YOUR_JSON_FILE>")
    
    client.task.transfer(fs.createReadStream('<YOUR_JSON_FILE>'));
    

Note that, once you've uploaded a video and the platform has finished indexing it, you can provide custom metadata. You can use custom metadata to filter search results or videos.