Upload videos

A video indexing task represents a request to upload and index a video. The TasksWrapper class provides methods to manage your video indexing tasks.

Methods

Create a video indexing task

Description: This method creates a new video indexing task that uploads and indexes a video.

The videos you wish to upload must meet the following requirements:

  • Video resolution: Must be at least 360x360 and must not exceed 3840x2160.
  • Aspect ratio: Must be one of 1:1, 4:3, 4:5, 5:4, 16:9, 9:16, or 17:9.
  • Video and audio formats: Your video files must be encoded in the video and audio formats listed on the FFmpeg Formats Documentation page. For videos in other formats, contact us at support@twelvelabs.io.
  • Duration: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 60 minutes (3600s). In a future release, the maximum duration for Pegasus will be 2 hours (7,200 seconds).
  • File size: Must not exceed 2 GB. If you require different options, contact us at support@twelvelabs.io.

If both Marengo and Pegasus are enabled for your index, the most restrictive prerequisites will apply.

Function signature and example:

1create(request: TwelvelabsApi.TasksCreateRequest, requestOptions?: Tasks.RequestOptions): core.HttpResponsePromise<TwelvelabsApi.TasksCreateResponse>;
NameTypeRequiredDescription
requestTasksCreateRequestYesParameters for creating the new video indexing task.
requestOptionsRequestOptionsNoRequest-specific configuration.

The TasksCreateRequest interface defines the parameters for creating a new video indexing task:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the video will be uploaded.
videoFileFile | fs.ReadStream | BlobNoThe video file to upload. This parameter can be a File, an fs.ReadStream, or a Blob.
videoUrlstringNoThe publicly accessible URL of the video you want to upload.
enableVideoStreambooleanNoIndicates if the platform stores the video for streaming. When set to true, the platform stores the video, and you can retrieve its URL. For details, see the Retrieve video information section.

Return value: Returns a Promise that resolves to a TasksCreateResponse instance.

The TasksCreateResponse interface contains the following properties:

NameTypeDescription
idstringThe unique identifier of your video indexing task.
videoIdstringThe unique identifier of the video associated with your video indexing task.

API Reference: Create a video indexing task.

Retrieve a video indexing task

Description: This method retrieves the details of a specific video indexing task.

Function signature and example:

1retrieve(taskId: string, requestOptions?: Tasks.RequestOptions): core.HttpResponsePromise<TwelvelabsApi.TasksRetrieveResponse>;

Parameters:

NameTypeRequiredDescription
taskIdstringYesThe unique identifier of the video indexing task to retrieve.
requestOptionsRequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to a TasksRetrieveResponse instance representing the retrieved video indexing task..

The TasksRetrieveResponse interface extends VideoIndexingTask and contains the following properties:

NameTypeDescription
idstringThe unique identifier of the task.
videoIdstringThe unique identifier of the video associated with the specified video indexing task.
createdAtstringThe date and time, in the RFC 3339 format, that the task was created.
updatedAtstringThe date and time, in the RFC 3339 format, that the task object was last updated.
statusstringThe status of the video indexing task.
indexIdstringThe unique identifier of the index to which the video must be uploaded.
systemMetadataVideoIndexingTaskSystemMetadataSystem-generated metadata about the video.
hlsHlsObjectHLS streaming information for the video.

The VideoIndexingTaskSystemMetadata interface contains the following properties:

NameTypeDescription
durationnumberThe duration of the video.
filenamestringThe filename of the video.
heightnumberThe height of the video.
widthnumberThe width of the video.

The HlsObject interface contains the following properties:

NameTypeDescription
videoUrlstringThe URL of the video for HLS streaming.
thumbnailUrlsstring[]An array containing the URL of the thumbnail.
statusstringThe encoding status of the video file from its original format to a streamable format.
updatedAtstringThe date and time, in the RFC 3339 format, that the encoding status was last updated.

API Reference: Retrieve a video indexing task.

Wait for a video indexing task to complete

Description: This method waits until a video indexing task is completed. It checks the task status at regular intervals by retrieving its details. If you provide a callback function, the method calls it after each status check with the current task object. This allows you to monitor the progress of the task.

1waitForDone(taskId: string, options?: {
2sleepInterval?: number;
3callback?: (task: TwelvelabsApi.TasksRetrieveResponse) => void | Promise<void>;
4}, requestOptions?: Tasks.RequestOptions): Promise<TwelvelabsApi.TasksRetrieveResponse>;

Parameters:

NameTypeRequiredDescription
taskIdstringYesThe unique identifier of the task to wait for.
optionsobjectNoOptions for the wait operation.
options.sleepIntervalnumberNoThe time in seconds to wait between status checks. Must be greater than 0. Default: 5.0.
options.callback(task: TasksRetrieveResponse) => void | Promise<void>NoAn optional function to call after each status check. It receives the current task object. Use this to monitor progress.
requestOptionsRequestOptionsNoRequest-specific configuration.

Return value: A Promise that resolves to a TasksRetrieveResponse representing the completed task. See the Retrieve a video indexing task section above for complete property details.

List video indexing tasks

Description: This method returns a paginated list of the video indexing tasks in your account based on the provided parameters. By default, the platform returns your video indexing tasks sorted by creation date, with the newest at the top of the list.

Function signature and example:

1list(request?: TwelvelabsApi.TasksListRequest, requestOptions?: Tasks.RequestOptions): Promise<core.Page<TwelvelabsApi.VideoIndexingTask>>;

Parameters:

NameTypeRequiredDescription
requestTasksListRequestNoParameters for filtering the list of tasks. Default: {}.
requestOptionsRequestOptionsNoRequest-specific configuration.

The TasksListRequest interface defines the parameters for listing video indexing tasks:

NameTypeRequiredDescription
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
sortBystringNoThe field to sort on. Available options: updated_at, created_at. Default: created_at.
sortOptionstringNoThe sorting direction. Available options: asc, desc. Default: desc.
indexIdstringNoFilter by the unique identifier of an index.
statusTasksListRequestStatusItem | TasksListRequestStatusItem[]NoFilter by one or more video indexing task statuses. Available options: ready, uploading, validating, pending, queued, indexing, failed.
filenamestringNoFilter by filename.
durationnumberNoFilter by duration. Expressed in seconds.
widthnumberNoFilter by width.
heightnumberNoFilter by height.
createdAtstringNoFilter video indexing tasks by the creation date and time, in the RFC 3339 format. The platform returns the video indexing tasks that were created on the specified date at or after the given time.
updatedAtstringNoFilter video indexing tasks by the last update date and time, in the RFC 3339 format. The platform returns the video indexing tasks that were updated on the specified date at or after the given time.

Return value: Returns a Promise that resolves to a Page<VideoIndexingTask> object that implements AsyncIterable, allowing you to iterate through the results.

The VideoIndexingTask interface contains the following properties:

NameTypeDescription
idstringThe unique identifier of the task.
videoIdstringThe unique identifier of the video associated with the specified video indexing task.
createdAtstringThe date and time, in the RFC 3339 format, that the task was created.
updatedAtstringThe date and time, in the RFC 3339 format, that the task object was last updated.
statusstringThe status of the video indexing task.
indexIdstringThe unique identifier of the index to which the video must be uploaded.
systemMetadataVideoIndexingTaskSystemMetadataSystem-generated metadata about the video.

The VideoIndexingTaskSystemMetadata interface contains the following properties:

NameTypeDescription
durationnumberThe duration of the video.
filenamestringThe filename of the video.
heightnumberThe height of the video.
widthnumberThe width of the video.

API Reference: List video indexing tasks.

Delete a video indexing task

Description: This method deletes an existing video indexing task. This action cannot be undone. You can only delete video indexing tasks for which the status is ready or failed. If the status of your video indexing task is ready, you must first delete the video vector associated with your video indexing task.

Function signature and example:

1delete(taskId: string, requestOptions?: Tasks.RequestOptions): core.HttpResponsePromise<void>;

Parameters:

NameTypeRequiredDescription
taskIdstringYesThe unique identifier of the video indexing task to delete.
requestOptionsRequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to void. This method doesn’t return any data upon successful completion.

API Reference: Delete a video indexing task.

Import videos

Description: An import represents the process of uploading and indexing all videos from the specified integration. This method initiates an asynchronous import and returns two lists: videos that will be imported, and videos that will not be imported, typically due to unmet prerequisites. The actual uploading and indexing of videos occur asynchronously after you invoke this method.

The videos you wish to upload must meet the following requirements:

  • Video resolution: Must be at least 360x360 and must not exceed 3840x2160.
  • Aspect ratio: Must be one of 1:1, 4:3, 4:5, 5:4, 16:9, 9:16, or 17:9.
  • Video and audio formats: Your video files must be encoded in the video and audio formats listed on the FFmpeg Formats Documentation page. For videos in other formats, contact us at support@twelvelabs.io.
  • Duration: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 60 minutes (3600s). In a future release, the maximum duration for Pegasus will be 2 hours (7,200 seconds).
  • File size: Must not exceed 2 GB. If you require different options, contact us at support@twelvelabs.io.

If both Marengo and Pegasus are enabled for your index, the most restrictive prerequisites will apply.

The videos you wish to upload must meet the following requirements:

  • Video resolution: Must be at least 360x360 and must not exceed 3840x2160.
  • Aspect ratio: Must be one of 1:1, 4:3, 4:5, 5:4, 16:9, 9:16, or 17:9.
  • Video and audio formats: Your video files must be encoded in the video and audio formats listed on the FFmpeg Formats Documentation page. For videos in other formats, contact us at support@twelvelabs.io.
  • Duration: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 60 minutes (3600s). In a future release, the maximum duration for Pegasus will be 2 hours (7,200 seconds).
  • File size: Must not exceed 2 GB. If you require different options, contact us at support@twelvelabs.io.

If both Marengo and Pegasus are enabled for your index, the most restrictive prerequisites will apply.

The videos you wish to upload must meet the following requirements:

  • Video resolution: Must be at least 360x360 and must not exceed 3840x2160.
  • Aspect ratio: Must be one of 1:1, 4:3, 4:5, 5:4, 16:9, 9:16, or 17:9.
  • Video and audio formats: Your video files must be encoded in the video and audio formats listed on the FFmpeg Formats Documentation page. For videos in other formats, contact us at support@twelvelabs.io.
  • Duration: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 60 minutes (3600s). In a future release, the maximum duration for Pegasus will be 2 hours (7,200 seconds).
  • File size: Must not exceed 2 GB. If you require different options, contact us at support@twelvelabs.io.

If both Marengo and Pegasus are enabled for your index, the most restrictive prerequisites will apply.

The videos you wish to upload must meet the following requirements:

  • Video resolution: Must be at least 360x360 and must not exceed 3840x2160.
  • Aspect ratio: Must be one of 1:1, 4:3, 4:5, 5:4, 16:9, 9:16, or 17:9.
  • Video and audio formats: Your video files must be encoded in the video and audio formats listed on the FFmpeg Formats Documentation page. For videos in other formats, contact us at support@twelvelabs.io.
  • Duration: For Marengo, it must be between 4 seconds and 2 hours (7,200s). For Pegasus, it must be between 4 seconds and 60 minutes (3600s). In a future release, the maximum duration for Pegasus will be 2 hours (7,200 seconds).
  • File size: Must not exceed 2 GB. If you require different options, contact us at support@twelvelabs.io.

If both Marengo and Pegasus are enabled for your index, the most restrictive prerequisites will apply.

Function signature and example:

1create(integrationId: string, request: TwelvelabsApi.tasks.TransfersCreateRequest, requestOptions?: Transfers.RequestOptions): core.HttpResponsePromise<TwelvelabsApi.tasks.TransfersCreateResponse>;

Parameters:

NameTypeRequiredDescription
integrationIdstringYesThe unique identifier of the integration for which you want to import videos.
requestTransfersCreateRequestYesParameters for the import operation.
requestOptionsRequestOptionsNoRequest-specific configuration.

The TransfersCreateRequest interface defines the parameters for importing videos:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the videos are being uploaded.
incrementalImportbooleanNoSpecifies whether or not incremental sync is enabled. If set to false, the platform will synchronize all the files in the bucket. Default: true.
retryFailedbooleanNoDetermines whether the platform retries failed uploads. When set to true, the platform attempts to re-upload files that failed during the initial upload process. Default: false.
userMetadataRecord<string, unknown>NoMetadata that helps you categorize your videos. You can specify a list of keys and values. Keys must be of type string, and values can be of the following types: string, integer, float or boolean. The metadata you specify applies to all videos imported in this request.

Return value: Returns a Promise that resolves to a TransfersCreateResponse object containing two lists: videos that will be imported, and videos that will not be imported.

The TransfersCreateResponse interface contains the following properties:

NameTypeDescription
videosTransfersCreateResponseVideosItem[]A list of the videos that will be uploaded and indexed.
failedFilesTransfersCreateResponseFailedFilesItem[]A list of the video files that failed to import. Typically, these files did not meet the upload requirements.

The TransfersCreateResponseVideosItem interface contains the following properties:

NameTypeDescription
videoIdstringThe unique identifier of a video. This identifier identifies both the video itself and the associated video indexing task.
filenamestringThe filename of the video.

The TransfersCreateResponseFailedFilesItem interface contains the following properties:

NameTypeDescription
filenamestringThe filename of the video that failed to be imported.
errorMessagestringThe error message if the import failed.

API Reference: Import videos.

Related guide: Cloud-to-cloud integrations.

Retrieve import status

Description: This method retrieves the current status for each video from a specified integration and index, returning lists of videos grouped by their import status.

Function signature and example:

1getStatus(integrationId: string, request: TwelvelabsApi.tasks.TransfersGetStatusRequest, requestOptions?: Transfers.RequestOptions): core.HttpResponsePromise<TwelvelabsApi.tasks.TransfersGetStatusResponse>;

Parameters:

NameTypeRequiredDescription
integrationIdstringYesThe unique identifier of the integration for which you want to retrieve the status of your imported videos.
requestTransfersGetStatusRequestYesParameters for retrieving the import status.
requestOptionsRequestOptionsNoRequest-specific configuration.

The TransfersGetStatusRequest interface defines the parameters for retrieving import status:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index for which you want to retrieve the status of your imported videos.

Return value: Returns a Promise that resolves to a TransfersGetStatusResponse object containing lists of videos grouped by status.

The TransfersGetStatusResponse interface contains the following properties:

NameTypeDescription
notImportedstring[]An array of filenames that haven’t yet been imported.
validatingVideoItem[]An array of videos that are being validated.
pendingVideoItem[]An array of videos that are pending.
queuedVideoItem[]An array of videos that are queued for import.
indexingVideoItem[]An array of videos that are being indexed.
readyVideoItem[]An array of videos that have successfully been imported.
failedVideoItemFailed[]An array of videos that failed to import.

The VideoItem interface contains the following properties:

NameTypeDescription
videoIdstringThe unique identifier of the video.
filenamestringThe name of the video file.
createdAtDateThe date and time, in the RFC 3339 format, when the video was added to the import process.

The VideoItemFailed interface contains the following properties:

NameTypeDescription
filenamestringThe name of the video file.
createdAtDateThe date and time, in the RFC 3339 format, when the video was added to the import process.
errorMessagestringThe error message explaining why the video failed to import.

API Reference: Retrieve import status.

Related guide: Cloud-to-cloud integrations.

Retrieve import logs

Description: This method returns a chronological list of import operations for the specified integration. The list is sorted by creation date, with the oldest imports first. Each item in the list contains the number of videos in each status and detailed error information for failed uploads, including filenames and error messages. Use this method to track import progress and troubleshoot potential issues across multiple operations.

Function signature and example:

1getLogs(integrationId: string, requestOptions?: Transfers.RequestOptions): core.HttpResponsePromise<TwelvelabsApi.tasks.TransfersGetLogsResponse>;

Parameters:

NameTypeRequiredDescription
integrationIdstringYesThe unique identifier of the integration for which you want to retrieve the import logs. You can retrieve it from the Integrations page.
requestOptionsRequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to a TransfersGetLogsResponse object containing a chronological list of import operations for the specified integration.

The TransfersGetLogsResponse interface contains the following properties:

NameTypeDescription
dataImportLog[]An array that contains the import logs.

The ImportLog interface contains the following properties:

NameTypeDescription
indexIdstringThe unique identifier of the index associated with this import.
indexNamestringThe name of the index associated with this import.
createdAtDateThe date and time, in the RFC 3339 format, when the import process was initiated.
endedAtDateThe date and time, in the RFC 3339 format, when the platform completed importing your videos. A null value indicates that the import process is still ongoing.
videoStatusImportLogVideoStatusCounts of files in different statuses.
failedFilesImportLogFailedFilesItem[]An array containing the video files that failed to import, along with details about the error.

The ImportLogVideoStatus interface contains the following properties:

NameTypeDescription
readynumberCount of videos that have successfully been imported.
validatingnumberCount of videos that are being validated.
queuednumberCount of videos that are queued for import.
pendingnumberCount of videos that are pending.
indexingnumberCount of videos that are being indexed.
failednumberCount of videos that failed to import.

The ImportLogFailedFilesItem interface contains the following properties:

NameTypeDescription
filenamestringThe name of the video file that failed to import.
errorMessagestringA human-readable error message.

API Reference: Retrieve import logs.

Related guide: Cloud-to-cloud integrations.

Error codes

This section lists the most common error messages you may encounter while uploading videos.

  • video_resolution_too_low
    • The resolution of the video is too low. Please upload a video with resolution between 360x360 and 3840x2160. Current resolution is {current_resolution}.
  • video_resolution_too_high
    • The resolution of the video is too high. Please upload a video with resolution between 360x360 and 3840x2160. Current resolution is {current_resolution}.
  • video_resolution_invalid_aspect_ratio
    • The aspect ratio of the video is invalid. Please upload a video with aspect ratio between 1:1 and 2.4:1. Current resolution is {current_resolution}.
  • video_duration_too_short
    • Video is too short. Please use video with duration between 10 seconds and 2 hours(7200 seconds). Current duration is {current_duration} seconds.
  • video_duration_too_long
    • Video is too long. Please use video with duration between 10 seconds and 2 hours(7200 seconds). Current duration is {current_duration} seconds.
  • video_file_broken
    • Cannot read video file. Please check the video file is valid and try again.
  • task_cannot_be_deleted
    • (Returns raw error message)
  • usage_limit_exceeded
  • video_filesize_too_large
    • The video is too large. Please use a video with a size less than {maximum_size}. The current size is {current_file_size}.