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:

async transcription(
  indexId: string,
  id: string,
  filter: VideoFilterOptions = {},
  options: RequestOptions = {},
): Promise<Models.VideoValue[]>
const response = await client.index.video.transcription(
  '<YOUR_INDEX_ID>',
  '<YOUR_VIDEO_ID'
)

response.forEach((transcript, index) => {
  console.log(`\nTranscript ${index + 1}:`);
  console.log(`  Start time: ${transcript.start} seconds`);
  console.log(`  End time: ${transcript.end} seconds`);
  console.log(`  Transcription: ${transcript.value}`);
});

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe 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.
filterVideoFilterOptionsNoParameters for specifying the start and end of the time range (in seconds) to retrieve transcription for. Defaults to {}.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

The VideoFilterOptions interface defines the parameters for selecting a specific part of a video:

NameTypeRequiredDescription
startnumberNoThe start of the time range (in seconds).
endnumberNoThe end of the time range (in seconds).

Return value: Returns a Promise that resolves to an array of Models.VideoValue instances.

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:

async textInVideo(
  indexId: string,
  id: string,
  filter: VideoFilterOptions = {},
  options: RequestOptions = {},
): Promise<Models.VideoValue[]>
const response = await client.index.video.textInVideo(
  '<YOUR_INDEX_ID>',
  '<YOUR_VIDEO_ID>',
  { start:100, end:300}  
)

response.forEach((text, index) => {
  console.log(`\nSegment ${index + 1}:`);
  console.log(`  Start time: ${text.start} seconds`);
  console.log(`  End time: ${text.end} seconds`);
  console.log(`  Transcription: ${text.value}`);
});

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the video has been uploaded.
idstringYesThe unique identifier of the video.
filterVideoFilterOptionsNoParameters for specifying the start and end of the time range (in seconds) to retrieve OCRs for. Defaults to {}.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

The VideoFilterOptions interface defines the parameters for selecting a specific part of a video:

NameTypeRequiredDescription
startnumberNoThe start of the time range (in seconds).
endnumberNoThe end of the time range (in seconds)..

Return value: Returns a Promise that resolves to an array of Models.VideoValue instances.

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:

async logo(
  indexId: string,
  id: string,
  filter: VideoFilterOptions = {},
  options: RequestOptions = {},
): Promise<Models.VideoValue[]>
const response = await client.index.video.logo(
  '<YOUR_INDEX_ID>',
  '<YOUR_VIDEO_ID>',
  { start:100, end:300}  
)

response.forEach((logo, index) => {
  console.log(`\nLogo ${index + 1}:`);
  console.log(`  Start time: ${logo.start} seconds`);
  console.log(`  End time: ${logo.end} seconds`);
  console.log(`  Logo: ${logo.value}`);
});

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the video has been uploaded.
idstringYesThe unique identifier of the video.
filterVideoFilterOptionsNoParameters for specifying the start and end of the time range (in seconds) to retrieve logos for. Defaults to {}.
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

The VideoFilterOptions interface defines the parameters for selecting a specific part of a video:

NameTypeRequiredDescription
startnumberNoThe start of the time range (in seconds).
endnumberNoThe end of the time range (in seconds)..

Return value: Returns a Promise that resolves to an array of Models.VideoValue instances.

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:

async thumbnail(indexId: string, id: string, time?: number, options: RequestOptions = {}): Promise<string> 
const response = await client.index.video.thumbnail(
  '<YOUR_INDEX_ID>',
  '<YOUR_VIDEO_ID',
  10
)

console.log(`\nThumbnail URL: ${response}`);

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the video has been uploaded.
idstringYesThe unique identifier of the video.
timenumberNoThe 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..
optionsRequestOptionsNoAdditional options for the request. Defaults to {}.

Return value: Returns a Promise that resolves to a string 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.