Extract video data

The resources.Video class provides methods to extract data from the videos you've uploaded to the platform.

Methods

Extract transcriptions

Description: This method retrieves a transcription of the spoken words.

Function signature and example:

def transcription(
    self,
    index_id: str,
    id: str,
    *,
    start: Optional[float] = None,
    end: Optional[float] = None,
    **kwargs
) -> RootModelList[models.VideoValue]
response = client.index.video.transcription(
    index_id="<YOUR_INDEX_ID>",
    id="<YOUR_VIDEO_ID>",
    start=100,
    end=300
)

for i, transcript in enumerate(response, start=1):
    print(f"\nTranscript {i}:")
    print(f"  Start time: {transcript.start} seconds")
    print(f"  End time: {transcript.end} seconds")
    print(f"  Transcription: {transcript.value}")

Parameters:

NameTypeRequiredDescription
index_idstringYesThe unique identifier of the index to which the video has been uploaded.
idstringYesThe unique identifier of the video for which you want to retrieve a transcription.
startOptional[float]NoThe start of the time range (in seconds) for which you want to retrieve a transcription.
endOptional[float]NoThe end of the time range (in seconds) for which you want to retrieve a transcription.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a RootModelList containing models.VideoValue objects, each representing a segment of the transcription.

API Reference: For a description of each field in the request and response, see the Retrieve a transcription page.

Related guide: Extract transcriptions.

Extract text recognized in video (OCR)

Description: This method retrieves text recognized in video (OCR).

Function signature and example:

def text_in_video(
    self,
    index_id: str,
    id: str,
    *,
    start: Optional[float] = None,
    end: Optional[float] = None,
    **kwargs
) -> RootModelList[models.VideoValue]
response = client.index.video.text_in_video(
    index_id="<YOUR_INDEX_ID>",
    id="<YOUR_VIDEO_ID>",
    start=100,
    end=300
)

for i, text in enumerate(response, start=1):
    print(f"\nSegment {i}:")
    print(f"  Start time: {text.start} seconds")
    print(f"  End time: {text.end} seconds")
    print(f"  Text: {text.value}")

Parameters:

NameTypeRequiredDescription
index_ddstringYesThe unique identifier of the index to which the video has been uploaded.
idstringYesThe unique identifier of the video.
startOptional[float]NoThe start of the time range (in seconds) to retrieve OCRs for.
endOptional[float]NoThe end of the time range (in seconds) to retrieve OCRs for.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a RootModelList containing models.VideoValue objects, each representing a segment of recognized text in the video.

API Reference: For a description of each field in the request and response, see the Retrieve text recognized in video page.

Related guide: Extract text recognized in video (OCR).

Extract logos

Description: This method retrieves information about the logos detected in a specific video.

Function signature and example:

def logo(
    self,
    index_id: str,
    id: str,
    *,
    start: Optional[float] = None,
    end: Optional[float] = None,
    **kwargs
) -> RootModelList[models.VideoValue]
response = client.index.video.logo(
    index_id="<YOUR_INDEX_ID>",
    id="<YOUR_VIDEO_ID>",
    start=100,
    end=300
)

for i, logo in enumerate(response, start=1):
    print(f"\nLogo {i}:")
    print(f"  Start time: {logo.start} seconds")
    print(f"  End time: {logo.end} seconds")
    print(f"  Logo: {logo.value}")

Parameters:

NameTypeRequiredDescription
index_idstringYesThe unique identifier of the index to which the video has been uploaded.
idstringYesThe unique identifier of the video.
startOptional[float]NoThe start of the time range (in seconds) to analyze for logos.
endOptional[float]NoThe end of the time range (in seconds) to analyze for logos.
**kwargsdictNpAdditional keyword arguments for the request.

Return value: Returns a RootModelList containing models.VideoValue objects, each representing a segment where a logo was detected in the video.

API Reference: For a description of each field in the request and response, see the Extract logos page.

Related guide: Extract logos.

Extract thumbnails

Description: This method retrieves a thumbnail of a video. To use this feature, you must enable thumbnail generation for the index to which the video has been uploaded. For details, see the Create indexes page.

Function signature and example:

def thumbnail(
    self,
    index_id: str,
    id: str,
    *,
    time: Optional[float] = None,
    **kwargs,
) -> str
response = client.index.video.thumbnail(
    index_id="<YOUR_INDEX_ID>",
    id="<YOUR_VIDEO_ID>",
    time=10
)

print(f"Thumbnai URL: {response}")

Parameters:

NameTypeRequiredDescription
index_idstrYesThe unique identifier of the index to which the video has been uploaded.
idstrYesThe unique identifier of the video.
timeOptional[float]NoThe time in seconds at which to retrieve the thumbnail. If you don't specify this parameter, the platform retrieves a thumbnail from the middle of the video.
**kwargsdictNoAdditional keyword arguments for the request.

Return value: Returns a str representing the URL of the thumbnail.

API Reference: For a description of each field in the request and response, see the Retrieve a thumbnail page.

Related guide: Retrieve thumbnails.