Use the OSS data indexing feature to build an intelligent semantic search system for videos from Internet Protocol camera (IPC) devices. This system lets you perform semantic searches on collected videos and is ideal for scenarios such as smart security.
Use the IPC Scenario - Content-aware Price Calculator to estimate the potential costs of the AI content-aware features in this solution. (If you are not logged on to your Alibaba Cloud account, log on and then click the link again.)
Solution overview
Building the intelligent semantic search system involves two steps:
-
Create a bucket and upload videos: Create a bucket to store the raw video files from your IPC devices. Then, upload the videos that you want to process. These videos provide the source data for your searches.
-
Enable the AISearch feature: Enable the AISearch feature for the bucket. This enables intelligent searches that use natural language descriptions.
Solution advantages
-
Semantic search: Enables precise searches using natural language descriptions and multiple conditions. This helps you quickly locate specific video frames in complex scenarios.
-
Multimodal search: Offers unified management and search capabilities for various data types, such as videos, images, and text. This reduces technical complexity and O&M costs.
-
Horizontal scaling: OSS offers unlimited capacity and scalability. This allows it to easily handle massive data growth.
1. Create a bucket and upload videos
-
Log on to the OSS console.
On the Buckets page, click Create Bucket.
On the Create Bucket page, enter a bucket name. Use a business-related name, such as
ipc-videos-oss-metaquery-demo. You can keep the default settings for the other parameters.Click Create. On the success page, click Go to Bucket.
On the Objects page, click . Select the video files that you want to upload, such as videoA.mp4, videoB.mp4, and videoC.mp4. Keep the default settings for the other parameters and click Upload Object.
(Optional) Add tags to the uploaded video files. In the Actions column of the target file, choose
> Tag. In the dialog box that appears, add key-value pairs. For example, you can set the key to need-seekand the value totrueto use as a filter condition when you create the index. You can also set the key tocameraand the value tocamera-ato use as a filter condition for queries. Click OK. Tags enable more precise filtering during indexing and searching.
2. Enable the AISearch feature
Enable the AISearch feature for the bucket to enable precise searches of videos that use natural language descriptions and multiple conditions.
Note
Building the metadata index takes some time. The duration depends on the number of objects in the bucket. If it takes too long, you can refresh the page to check the enabling status. |
|
Verify the results
Enter a descriptive phrase, such as a yard with a parked car, and the system returns relevant videos that match the description.
|
|
Going live
When you integrate this capability into a production environment, consider the following aspects:
Production data ingestion
In a typical business scenario, monitoring devices, such as IPCs, continuously generate large amounts of video data. We recommend that you integrate the OSS SDK to upload recorded video segments to the specified bucket in real-time. This ensures the stability and timeliness of data uploads, which improves the overall availability and real-time processing capabilities of the system.
The following example shows how to use the OSS Python SDK's Upload Manager to upload a video file:
Search capability integration
In a production environment, we recommend that you integrate the search feature into your backend service. You can use the OSS SDK to make automated calls and avoid performing manual operations in the console.
The following code example shows how to build an XML request that complies with the OSS MetaQuery specification to retrieve search results:
After running the program, you can enter a descriptive phrase (such as a yard with a parked car) to perform a query. The system returns search results that match the description from the data index. You can view the video details using the URL.
Found 1 matching result:
File 1:
URI: oss://ipc-videos-oss-metaquery-demo/videoA.mp4
File name: videoA.mp4
Size: 2311252
Last modified: 2025-05-23T17:38:10+08:00
ContentType: video/mp4
MediaType: video
File URL (signed URL): https://ipc-videos-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/%E8%A7%86%E9%A2%91A.mp4?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250523T094511Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250523%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=0bf38092c42a179ff0e8334c8bea3fd92f5a78599038e816e2ed3e02755542af
--------------------
Set up tag filtering
When you deal with massive amounts of video data, managing files by path alone is often inefficient for searching and categorization. We recommend that you use the OSS object tagging feature. You can add key-value tags to files to quickly filter and categorize data based on your business needs, such as filtering by camera ID or geographic region.
Assume that you want to analyze the following three video files in the system: videoA.mp4, videoB.mp4, and videoC.mp4.
|
videoA.mp4 |
videoB.mp4 |
videoC.mp4 |
|
|
|
|
|
Backyard video, marked as shot by camera-a |
Sales video, marked as shot by camera-b |
Backyard video, similar in content to video A, marked as shot by camera-c |
Tags can be set when you upload files or dynamically managed after the upload to meet the requirements of different business scenarios.
Set tags during upload
You can set tags while uploading video files to combine the upload and tag management operations. This improves the efficiency of data management.
The following example shows how to use the OSS Python SDK's Upload Manager to upload a video file and set tags at the same time:
Manage tags after upload
If a file is already uploaded, you can add or modify its tags at any time. This ensures the dynamic maintenance and accuracy of data tags.
The following example shows how to call the relevant interface to add tags using the Python SDK:
Combine tag filtering with search
The following example shows how to use the OSS Python SDK to initiate a query request that combines semantic understanding with tag filtering:
After running the program, you can filter for videos that contain a yard with a parked car:
-
In the descriptive field, enter the following search keyword:
a yard with a parked car -
Set the following tag filter condition:
camera = camera-a
In this example, both video A and video C contain a scene that matches the description a yard with a parked car. However, because you set a tag filter to return only results for videos marked with camera-a, the final search result includes only video A.
Sending DoMetaQuery request...
Request successful, HTTP status code: 200
Retrieved 2 initial matches from OSS. Starting client-side tag filtering...
[1] File 'videoA.mp4' matches all conditions:
File URL: https://ipc-videos-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/%E8%A7%86%E9%A2%91A.mp4?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250526T054908Z&x-oss-expires=900&x-oss-credential=LTAI********************%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=01bbf29790763d8e0f177d4cb0469cb00ae1c69d565219edb3866f75110b37ab
File path: videoA.mp4
-----------------------
Client-side filtering complete. Found 1 final matching result.




