Provide transcriptions for cloud-to-cloud transfers

Cloud-to-cloud transfers allow you to group multiple video indexing operations in a single API request. For a description of each field in the request and response, see the API Reference > Make a cloud-to-cloud transfer page.

Prerequisites

  • You’re familiar with the concepts that are described on the Platform overview page.
  • You've already created an index. For details, see the Create indexes page.
  • You already downloaded the list of videos in your AWS S3 bucket.
  • Your transcription files reside on an AWS S3 bucket, and they're publicly accessible.
  • Your transcription must be in the SRT or VTT format.
  • Your video must meet the following requirements:
    • Video resolution: must be greater than or equal to 360p and less than or equal to 1080p (FHD).
    • File size: must not exceed 2 GB.
    • Duration: must be between 10 seconds and 2 hours (7,200s).
      If you require different options, send us an email at support[at]twelvelabs.io.

📘

Note

For consistent search results, Twelve Labs recommends you upload 360p videos.

Procedure

  1. The Dashboard page allows you to download the list of videos in your AWS S3 bucket as a JSON file, and you can provide transcriptions by editing this file in a plain-text editor. Open the JSON file containing the videos you want to upload and update the transcription fields by adding the S3 URLs of your transcription files. The following example adds two transcription files: 01.srt and 02.srt:
[
  {
    "index_id": "629d807aa9e2a3a33a92c00b1",
    "language": "en",
    "object": "s3://twelve-labs-docs/01.mp4",
    "transcription": "s3://twelve-labs-docs/01.srt"
  },
  {
    "index_id": "629d807aa9e2a3a33a92c00b",
    "language": "en",
    "object": "s3://twelve-labs-docs/02.mp4",
    "transcription": "s3://twelve-labs-docs/02.srt"
  }
]
  1. Declare the /tasks/transfers endpoint:

    TASKS_TRANSFERS_URL = f"{API_URL}/tasks/transfers"
    
    const TASKS_TRANSFERS_URL = `${API_URL}/tasks/transfers`
    
  2. Read your JSON file. Open a stream making sure to replace the placeholders surrounded by <> with your values:

    file_path = "<YOUR_FILE_PATH>"
    file_name = "<YOUR_FILE_NAME>"
    file_stream = open(file_path, "rb")
    
    const file_path = '<YOUR_FILE_PATH>'
    const file_stream = fs.createReadStream(file_path)
    
  3. If you're using Python, store the file to upload in an array named file_param and specify that you want to make a multipart/form-data request. If you're using Node.js, store the file to upload in a variable named formData of type FormData:

    file_param = [
        ("file", (file_name, file_stream, "multipart/form-data")),
    ]
    
    let formData = new FormData()
    formData.append('file', file_stream)
    
  4. Upload the JSON file. Call the /tasks/transfers endpoint, store the result in a variable named response, and print the status code and the response:

    requests.post(TASKS_TRANSFERS_URL, headers=headers, files=file_param)
    print (f"Status code: {response.status_code}")
    pprint (response.json())
    
    let config = {
        method: 'post',
        url: TASKS_TRANSFERS_URL,
        headers: headers,
        data : formData,
    };
    resp = await axios(config)
    response = await resp.data
    console.log(`Status code: ${resp.status}`)
    console.log(response)