Upload videos

A video indexing task represents a request to upload and index a video. The TaskClientWrapper 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:

1def create(
2 self,
3 *,
4 index_id: str,
5 video_file: typing.Optional[core.File] = OMIT,
6 video_url: typing.Optional[str] = OMIT,
7 enable_video_stream: typing.Optional[bool] = OMIT,
8 request_options: typing.Optional[RequestOptions] = None,
9) -> TasksCreateResponse:

Parameters:

NameTypeRequiredDescription
index_idstrYesThe unique identifier of the index to which the video will be uploaded.
video_filetyping.
Optional
[core.File]
NoThe video file to upload.
video_urltyping.
Optional[str]
NoThe publicly accessible URL of the video you want to upload.
enable_video_streamtyping.
Optional[bool]
NoIndicates if the platform stores the video for streaming. When set to true, the platform stores the video, and you can retrieve its URL by. For details, see the Retrieve video information page.
request_optionstyping.
Optional
[RequestOptions]
NoRequest-specific configuration.

Return value: Returns a TasksCreateResponse instance.

The TasksCreateResponse interface contains the following properties:

NameTypeDescription
idstringThe unique identifier of your video indexing task.
video_idstringThe 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:

1def retrieve(
2 self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
3) -> TasksRetrieveResponse

Parameters:

NameTypeRequiredDescription
task_idstrYesThe unique identifier of the video indexing task to retrieve.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

Return value: Returns a TasksRetrieveResponse object representing the retrieved video indexing task.

The TasksRetrieveResponse class extends VideoIndexingTask and contains the following properties:

NameTypeDescription
idOptional[str]The unique identifier of the task.
video_idOptional[str]The unique identifier of the video associated with the specified video indexing task.
created_atOptional[str]The date and time, in the RFC 3339 format, that the task was created.
updated_atOptional[str]The date and time, in the RFC 3339 format, that the task object was last updated.
statusOptional[str]The status of the video indexing task.
index_idOptional[str]The unique identifier of the index to which the video must be uploaded.
system_metadataOptional[VideoIndexingTaskSystemMetadata]System-generated metadata about the video.
hlsOptional[HlsObject]HLS streaming information for the video.

The VideoIndexingTaskSystemMetadata class contains the following properties:

NameTypeDescription
durationOptional[float]The duration of the video.
filenameOptional[str]The filename of the video.
heightOptional[int]The height of the video.
widthOptional[int]The width of the video.

The HlsObject class contains the following properties:

NameTypeDescription
video_urlOptional[str]The URL of the video for HLS streaming.
thumbnail_urlsOptional[List[str]]An array containing the URL of the thumbnail.
statusOptional[HlsObjectStatus]The encoding status of the video file from its original format to a streamable format. Possible values: PROCESSING, COMPLETE, CANCELED, ERROR.
updated_atOptional[str]The 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.

Function signature and example:

1def wait_for_done(
2 self,
3 task_id: str,
4 *,
5 sleep_interval: float = 5.0,
6 callback: typing.Optional[
7 typing.Callable[[TasksRetrieveResponse], None]
8 ] = None,
9 request_options: typing.Optional[RequestOptions] = None,
10) -> TasksRetrieveResponse

Parameters:

NameTypeRequiredDescription
task_idstrYesThe unique identifier of the task to wait for.
sleep_intervalfloatNoThe time in seconds to wait between status checks. Must be greater than 0. Default: 5.0.
callbackOptional
[Callable
[[TasksRetrieveResponse], None]]
NoAn optional function to call after each status check, receiving the current task object. Use this to monitor progress.
request_optionsOptional[RequestOptions]NoRequest-specific configuration.

Return value: Returns a TasksRetrieveResponse object 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. 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:

1def list(
2 self,
3 *,
4 page: typing.Optional[int] = None,
5 page_limit: typing.Optional[int] = None,
6 sort_by: typing.Optional[str] = None,
7 sort_option: typing.Optional[str] = None,
8 index_id: typing.Optional[str] = None,
9 status: typing.Optional[
10 typing.Union[TasksListRequestStatusItem, typing.Sequence[TasksListRequestStatusItem]]
11 ] = None,
12 filename: typing.Optional[str] = None,
13 duration: typing.Optional[float] = None,
14 width: typing.Optional[int] = None,
15 height: typing.Optional[int] = None,
16 created_at: typing.Optional[str] = None,
17 updated_at: typing.Optional[str] = None,
18 request_options: typing.Optional[RequestOptions] = None,
19) -> SyncPager[VideoIndexingTask]

Parameters:

NameTypeRequiredDescription
pagetyping.Optional[int]NoThe page number to retrieve. Default: 1.
page_limittyping.Optional[int]NoThe number of items per page. Default: 10. Max: 50.
sort_bytyping.Optional[str]NoThe field to sort by: "created_at" or "updated_at". Default: "created_at".
sort_optiontyping.Optional[str]NoThe sort order: "asc" or "desc". Default: "desc".
index_idtyping.Optional[str]NoFilter by the unique identifier of an index.
statustyping.
Optional
[typing.Union
[TasksListRequestStatusItem, typing.Sequence
[TasksListRequestStatusItem]]]
NoFilter by task status. Options: "ready", "uploading", "validating", "pending", "queued", "indexing", or "failed". You can specify multiple statuses.
filenametyping.Optional[str]NoFilter by filename.
durationtyping.Optional[float]NoFilter by duration in seconds.
widthtyping.Optional[int]NoFilter by video width.
heighttyping.Optional[int]NoFilter by video height.
created_attyping.Optional[str]NoFilter 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.
updated_attyping.Optional[str]NoFilter 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.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

Return value: Returns a SyncPager[VideoIndexingTask] object that allows you to iterate through the paginated list of video indexing tasks.

The VideoIndexingTask class contains the following properties:

NameTypeDescription
idOptional[str]The unique identifier of the task.
video_idOptional[str]The unique identifier of the video associated with the specified video indexing task.
created_atOptional[str]The date and time, in the RFC 3339 format, that the task was created.
updated_atOptional[str]The date and time, in the RFC 3339 format, that the task object was last updated.
statusOptional[str]The status of the video indexing task.
index_idOptional[str]The unique identifier of the index to which the video must be uploaded.
system_metadataOptional[VideoIndexingTaskSystemMetadata]System-generated metadata about the video.

The VideoIndexingTaskSystemMetadata class contains the following properties:

NameTypeDescription
durationOptional[float]The duration of the video.
filenameOptional[str]The filename of the video.
heightOptional[int]The height of the video.
widthOptional[int]The 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:

1def delete(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None

Parameters:

NameTypeRequiredDescription
task_idstrYesThe unique identifier of the video indexing task to delete.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

Return value: None. 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:

1def create(
2 self,
3 integration_id: str,
4 *,
5 index_id: str,
6 incremental_import: typing.Optional[bool] = OMIT,
7 retry_failed: typing.Optional[bool] = OMIT,
8 user_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
9 request_options: typing.Optional[RequestOptions] = None,
10) -> TransfersCreateResponse

Parameters:

NameTypeRequiredDescription
integration_idstrYesThe unique identifier of the integration for which you want to import videos.
index_idstrYesThe unique identifier of the index to which the videos are being uploaded.
incremental_importtyping.Optional[bool]NoSpecifies whether incremental sync is enabled. If false, all files in the bucket are synchronized. Default: true.
retry_failedtyping.Optional[bool]NoDetermines whether to retry failed uploads. If true, the platform attempts to re-upload failed files. Default: false.
user_metadatatyping.Optional[typing.Dict[str, typing.Optional[typing.Any]]]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.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

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

The TransfersCreateResponse class contains the following properties:

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

The TransfersCreateResponseFailedFilesItem class contains the following properties:

NameTypeDescription
filenameOptional[str]The filename of the video that failed to be imported.
error_messageOptional[str]The error message if the import failed.

The TransfersCreateResponseVideosItem class contains the following properties:

NameTypeDescription
video_idOptional[str]The unique identifier of a video. This identifier identifies both the video itself and the associated video indexing task.
filenameOptional[str]The filename of the video.

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. Use this method to track import progress and troubleshoot potential issues across multiple operations.

Function signature and example:

1def get_status(
2 self,
3 integration_id: str,
4 *,
5 index_id: str,
6 request_options: typing.Optional[RequestOptions] = None
7) -> TransfersGetStatusResponse

Parameters:

NameTypeRequiredDescription
integration_idstrYesThe unique identifier of the integration for which to retrieve the status of imported videos.
index_idstrYesThe unique identifier of the index for which to retrieve the status of imported videos.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

Return value: Returns a TransfersGetStatusResponse object containing lists of videos grouped by status.

The TransfersGetStatusResponse class contains the following properties:

NameTypeDescription
not_importedOptional[List[str]]An array of filenames that haven’t yet been imported.
validatingOptional[List[VideoItem]]An array of videos that are being validated.
pendingOptional[List[VideoItem]]An array of videos that are pending.
queuedOptional[List[VideoItem]]An array of videos that are queued for import.
indexingOptional[List[VideoItem]]An array of videos that are being indexed.
readyOptional[List[VideoItem]]An array of videos that have successfully been imported.
failedOptional[List[VideoItemFailed]]An array of videos that failed to import.

The VideoItem class contains the following properties:

NameTypeDescription
video_idstrThe unique identifier of the video.
filenamestrThe name of the video file.
created_atdatetimeThe date and time, in the RFC 3339 format, when the video was added to the import process.

The VideoItemFailed class contains the following properties:

NameTypeDescription
filenamestrThe name of the video file.
created_atdatetimeThe date and time, in the RFC 3339 format, when the video was added to the import process.
error_messagestrThe 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, sorted by creation date with the oldest imports first. Each log entry includes the number of videos in each status and detailed error information for failed uploads.

Function signature and example:

1def get_logs(
2 self,
3 integration_id: str,
4 *,
5 request_options: typing.Optional[RequestOptions] = None
6) -> TransfersGetLogsResponse

Parameters:

NameTypeRequiredDescription
integration_idstrYesThe unique identifier of the integration for which to retrieve the import logs.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

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

The TransfersGetLogsResponse class contains the following properties:

NameTypeDescription
dataOptional[List[ImportLog]]An array that contains the import logs.

The ImportLog class contains the following properties:

NameTypeDescription
index_idOptional[str]The unique identifier of the index associated with this import.
index_nameOptional[str]The name of the index associated with this import.
created_atOptional[datetime]The date and time, in the RFC 3339 format, when the import process was initiated.
ended_atOptional[datetime]The 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.
video_statusOptional[ImportLogVideoStatus]Counts of files in different statuses.
failed_filesOptional[List[ImportLogFailedFilesItem]]An array containing the video files that failed to import, along with details about the error.

The ImportLogVideoStatus class contains the following properties:

NameTypeDescription
readyintCount of videos that have successfully been imported.
validatingintCount of videos that are being validated.
queuedintCount of videos that are queued for import.
pendingintCount of videos that are pending.
indexingintCount of videos that are being indexed.
failedintCount of videos that failed to import.

The ImportLogFailedFilesItem class contains the following properties:

NameTypeDescription
filenameOptional[str]The name of the video file that failed to import.
error_messageOptional[str]A 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}.