Extract video data
Videos contain combinations of images, spoken words, sounds, movements, and text. When you have a large library of videos, it might be difficult to know what’s in your videos and how to write a query that finds the exact moments you need. Although the platform doesn’t automatically extract any tags from your videos and doesn’t require you to use them when you perform searches, extracting information that appears in a video can help you get insights into the content of your videos. Instead of watching the entire video and annotating it manually, you can use information extracted by the platform to perform more fine-grained searches.
Prerequisites
- You’re familiar with the concepts that are described on the Platform overview page.
- You’ve already created an index, and the Marengo video understanding engine is enabled for this index.
- You’ve uploaded a video, and the platform has finished indexing it.
- To extract logos, the
logo
indexing option must be enabled for the index containing your video. - To extract thumbnails, the
thumbnail
add-on must be enabled for the index containing your video.
Extract transcriptions
To extract transcriptions, call the transcription
method of the index.video
object with the following parameters:
index_id
: A string representing the unique identifier of the index containing the video for which you want to extract transcriptions.video_id
: A string representing the unique identifier of the video.
The following example output was truncated for brevity:
Note that you can use the start
and end
query parameters to specify the time range for which you want to retrieve the transcription. The following example retrieves the transcription for the first 10 seconds of the video:
Extract text recognized in a video(OCR)
To extract the text recognized in a video, call the text_in_video
method of the index.video
object with the following parameters:
index_id
: A string representing the unique identifier of the index containing the video for which you extract text.video_id
: A string representing the unique identifier of the video.
Note that you can use the start
and end
parameters to specify the time range for which you want to retrieve the text. The following example retrieves the text for the first 10 seconds of the video:
Extract logos
To extract logos, call the logo
method of the index.video
object with the following parameters:
index_id
: A string representing the unique identifier of the index containing the video for which you want to extract logos.video_id
: A string representing the unique identifier of the video.
The output should look similar to the following one:
In this example output, the Hyundai logo appears in the specified video twice, as shown below:
- At 167 seconds from the start of the video:
- At 224 seconds from the start of the video:
Note that you can use the start
and end
parameters to specify the time range for which you want to extract logos. The following example extracts logos for the first 10 seconds of the video:
Retrieve thumbnails
The platform allows you to retrieve thumbnails for your videos or search results that you can display in your application. For example, you can retrieve thumbnails when:
- Your application displays previews for one or more videos. For example, users may want to see thumbnails of all the videos in an index before deciding which video they wish to delete.
- Your application displays previews for search results. For example, when users perform a search, your application could use thumbnails to give users a small view of each matching video clip.
Note the following about retrieving thumbnails:
- For videos: The platform allows you to retrieve a thumbnail from the middle of the video or a specific time, measured in seconds, from the beginning.
- For search results: The platform always returns a thumbnail from the middle of each matching video clip.
Each URL is unique and remains valid for one hour.
Depending on your use case, refer to the appropriate section below.
Retrieve a thumbnail of a video
To retrieve a thumbnail from the middle of a video, call the thumbnail
method of the index.video
object with the following parameters:
index_id
: A string representing the unique identifier of the index containing the video for which you want to retrieve a thumbnail.video_id
: A string representing the unique identifier of the video.
The output should look similar to the following one:
The following example code uses the time
parameter to specify the time, in seconds, at which the platform must retrieve a thumbnail:
Retrieve thumbnails for search results
When you perform a search on an index for which thumbnail generation is enabled, the platform returns a field named thumbnail_url
that contains a thumbnail from the middle of each matching video clip.
The following example code performs a search on an index for which thumbnail generation is enabled. Make sure to replace the placeholders surrounded by <>
with your values:
The following example output was truncated for brevity: