Frequently asked questions

Can I add more than one video to an index?

Yes. Indexes provide a mechanism for grouping related videos. For example, if you want to upload multiple videos from a car race, Twelve Labs recommends you create a single index for that race. Then, to find a specific moment in the race, you invoke the search endpoint only once instead of once for each index.
When you perform a search on an index that has more than one video, each object in the data array contains a field named video_id that shows the unique identifier of the matching video and the total_count field of the search_pool object indicates the number of videos in your index. The following example output shows results from two videos - 627df188ba9f116e5ea92a75 and 627de9b2ba9f116e5ea92a74, and the value of the total_count field is 2:

{
  "data": [
    {
      "score": 75.03,
      "start": 22,
      "end": 28,
      "metadata": [
        {
          "type": "visual"
        }
      ],
      "video_id": "627df188ba9f116e5ea92a75",
      "confidence": "mid"
    },
    {
      "score": 74.06,
      "start": 278,
      "end": 284,
      "metadata": [
        {
          "type": "visual"
        }
      ],
      "video_id": "627df188ba9f116e5ea92a75",
      "confidence": "mid"
    },
    {
      "score": 66.66,
      "start": 28,
      "end": 30,
      "metadata": [
        {
          "type": "visual"
        }
      ],
      "video_id": "627de9b2ba9f116e5ea92a74",
      "confidence": "low"
    }
  ],
  "page_info": {
    "limit_per_page": 10,
    "page_expired_at": "2022-05-16T05:14:54Z",
    "total_results": 5
  },
  "query": "car turning upside down",
  "search_options": [
    "visual"
  ],
  "search_pool": {
    "index_id": "627de802f18e21febd160ba9",
    "total_count": 2,
    "total_duration": 582
  }
}

List all the videos in an index

To list all the videos in an index, call the GET method of the /indexes/videos endpoint, replacing <YOUR_INDEX_ID> with the unique identifier of your index:

INDEX_ID = "<YOUR_INDEX_ID>"
INDEXES_VIDEOS_URL = f"{API_URL}/indexes/{INDEX_ID}/videos"
response = requests.get(INDEXES_VIDEOS_URL, headers=headers)
print (f'Status code: {response.status_code}')
pprint (response.json())
const INDEX_ID = 'YOUR_INDEX_ID'
const INDEXES_VIDEOS_URL = `${API_URL}/indexes/${INDEX_ID}/videos`
const config = {
    method: 'get',
    url: INDEXES_VIDEOS_URL,
    headers: headers,
}
const resp = await axios(config)
const response = await resp.data
console.log(resp.status)
console.log(JSON.stringify(response, null, 2))

The output should look similar to the following one. Note that, in the example output below, two videos named 01.mp4 and 02.mp4 are being stored in the index:

Status code: 200
{'data': [{'_id': '627df188ba9f116e5ea92a75',
           'created_at': '2022-05-13T05:50:00Z',
           'indexed_at': '2022-05-13T06:02:06Z',
           'metadata': {'duration': 552.92,
                        'filename': '01.mp4',
                        'fps': 25,
                        'height': 720,
                        'size': 148108668,
                        'width': 1280},
           'updated_at': '2022-05-13T05:50:00Z'},
          {'_id': '627de9b2ba9f116e5ea92a74',
           'created_at': '2022-05-13T05:16:34Z',
           'indexed_at': '2022-05-13T05:31:05Z',
           'metadata': {'duration': 30.033333,
                        'filename': '02.mp4',
                        'fps': 30,
                        'height': 270,
                        'size': 1570024,
                        'width': 480},
           'updated_at': '2022-05-13T05:16:34Z'}],
 'page_info': {'limit_per_page': 10,
               'page': 0,
               'total_page': 0,
               'total_results': 2}
}

Related topics

How do multiple search options work?

You can specify multiple search options in conjunction with the operator parameter to broaden or narrow your search. For details and examples, see the Using multiple sources of information section.