You can use the data indexing feature of Object Storage Service (OSS) to build an intelligent semantic search system for videos collected by Internet Protocol (IP) cameras. This system lets you perform semantic searches on your videos and is ideal for scenarios such as intelligent security.
Solution overview
To build an intelligent semantic search system, follow these two steps:
Create a bucket and upload videos: Create a bucket to store the original video files collected by IP cameras. Then, upload the video files to be processed. This provides the foundation for subsequent video searches.
Enable the AISearch feature: Enable the AISearch feature for the bucket to enable intelligent searches based on natural language descriptions.
Benefits
Semantic search: Supports precise searches based on natural language descriptions and multiple combined conditions. This lets you quickly locate target frames and fulfill search requirements in complex scenarios.
Multimodal search: Provides unified management and search capabilities for data such as videos, images, and text. This lowers the technical barrier and operations and maintenance (O&M) costs.
Horizontal scaling: OSS offers unlimited capacity and elastic scalability. It can easily handle massive data growth.
1. Create a bucket and upload videos
Log on to the OSS console.
Go to the Buckets page and click Create Bucket.
On the Create Bucket page, enter a bucket name that is related to your business, such as
ipc-videos-oss-metaquery-demo. You can keep the default settings for the other parameters.Click Create. After the bucket is created, click View Bucket.
On the File List page, click . Select the video files that you want to upload, such as Video A.mp4, Video B.mp4, and Video C.mp4. Keep the default configurations for the other parameters, and click Upload File.
(Optional) Configure tags for the uploaded video files. In the Actions column for the target file, choose . In the dialog box that appears, add tag key-value pairs. For example, set the tag key to
need-seekand the value totrueto use as a filter condition when you create the index. Set the tag key tocameraand the value tocamera-ato use as a filter condition for index queries. Click OK. Adding tags to videos allows for more precise filtering during indexing and searching.
2. Enable the AISearch feature
Enable the AISearch feature for the bucket to enable precise searches on videos based on natural language descriptions and multiple combined conditions.
Note Building the metadata index takes some time. The exact 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
Simply enter a descriptive text, such as a yard with a parked car, and the system returns the relevant videos that match the description.
|
|
Going live
When you need to integrate this capability into a production environment, consider the following aspects:
Production data ingestion
In real-world business scenarios, monitoring devices, such as IP cameras, continuously generate large amounts of video data. We recommend that you integrate the OSS software development kit (SDK) to upload recorded video segments to a specified bucket in real time. This ensures the stability and timeliness of data uploads and improves the overall system's availability and real-time processing capabilities.
The following example shows how to use the OSS Python SDK to call the file upload manager to upload a video:
Integrate search capabilities
In a production environment, we recommend that you integrate the search feature into your backend service. Use the OSS SDK to automate calls and avoid manual operations in the console.
The following code sample shows how to build an XML request that complies with OSS MetaQuery specifications to retrieve search results:
After you run the program, you can enter descriptive text, such as a yard with a parked car, to perform a search. The system uses the data index to return search results that match the description. You can use the URL to view the video details directly.
Found 1 matching result:
File 1:
URI: oss://ipc-videos-oss-metaquery-demo/VideoA.mp4
File name: VideoA.mp4
Size: 2311252
Modified time: 2025-05-23T17:38:10+08:00
ContentType: video/mp4
MediaType: video
File address (signed URL): https://ipc-videos-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/VideoA.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 tag filters
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 tagging feature to add key-value tags to files. This lets you quickly filter and categorize data based on business needs, such as filtering by camera ID or geographic region.
Assume that the system has three video files to be analyzed (VideoA.mp4, VideoB.mp4, and VideoC.mp4) as follows:
VideoA.mp4 | VideoB.mp4 | VideoC.mp4 |
|
|
|
Backyard video, marked as shot by camera-a | Vending video, marked as shot by camera-b | Backyard video, similar in content to Video A, marked as shot by camera-c |
You can set tags directly when you upload a file. You can also manage them dynamically after the upload to meet various business needs.
Set tags during upload
You can set tags while uploading video files to integrate upload and tag management operations. This improves data management efficiency.
The following example shows how to use the file upload manager of the OSS Python SDK to upload a video file and set tags at the same time:
Manage tags after upload
If a file is already uploaded, you can still add or modify its tags at any time. This ensures dynamic maintenance and accuracy of data tags.
The following example shows how to call the API operation using the Python SDK to add tags:
Search with tag filters
The following example shows how to use the OSS Python SDK to send a combined query request that uses both semantic understanding and tag filtering:
After you run the program, to filter for videos that contain a yard with a parked car, you can perform the following steps:
In the descriptive field, enter the search keyword:
a yard with a parked carSet the tag filter condition:
camera = camera-a
In this example, both Video A and Video C contain scenes that match the description a yard with a parked car. However, because you set a tag filter that retains only the search results for videos tagged with camera-a, the final search result includes only Video A.
Sending DoMetaQuery request...
Request successful, HTTP status code: 200
Got 2 initial matching results from OSS, starting client-side tag filtering...
[1] File 'VideoA.mp4' matches all conditions:
File address: https://ipc-videos-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/VideoA.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.
> More > Tagging



