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:
Name | Type | Required | Description |
---|---|---|---|
index_id | string | Yes | The unique identifier of the index to which the video has been uploaded. |
id | string | Yes | The unique identifier of the video for which you want to retrieve a transcription. |
start | Optional[float] | No | The start of the time range (in seconds) for which you want to retrieve a transcription. |
end | Optional[float] | No | The end of the time range (in seconds) for which you want to retrieve a transcription. |
**kwargs | dict | No | Additional 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:
Name | Type | Required | Description |
---|---|---|---|
index_dd | string | Yes | The unique identifier of the index to which the video has been uploaded. |
id | string | Yes | The unique identifier of the video. |
start | Optional[float] | No | The start of the time range (in seconds) to retrieve OCRs for. |
end | Optional[float] | No | The end of the time range (in seconds) to retrieve OCRs for. |
**kwargs | dict | No | Additional 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:
Name | Type | Required | Description |
---|---|---|---|
index_id | string | Yes | The unique identifier of the index to which the video has been uploaded. |
id | string | Yes | The unique identifier of the video. |
start | Optional[float] | No | The start of the time range (in seconds) to analyze for logos. |
end | Optional[float] | No | The end of the time range (in seconds) to analyze for logos. |
**kwargs | dict | Np | Additional 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:
Name | Type | Required | Description |
---|---|---|---|
index_id | str | Yes | The unique identifier of the index to which the video has been uploaded. |
id | str | Yes | The unique identifier of the video. |
time | Optional[float] | No | The 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. |
**kwargs | dict | No | Additional 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.