You can use the data indexing and frame capture features of Object Storage Service (OSS) to create an intelligent semantic indexing system for videos collected by IP cameras. This system can capture frames from the collected videos and search for videos based on semantic content, which is suitable for scenarios such as intelligent security.
Solution overview
To create an intelligent semantic indexing system, perform the following steps:
Create a bucket in which videos are stored: Create a bucket to store videos collected by IP cameras, upload the videos to be processed, and capture key frames based on a preset time interval for subsequent video search.
Create a bucket in which frames are stored: Create a bucket to store key frames captured from the videos and enable the AISearch feature for intelligent video search based on semantic content.
Benefits
Intelligent media processing: OSS and Intelligent Media Management (IMM) are used together to process and analyze large-scale video data, automatically process large-scale video data uploaded to OSS, extract key frames, generate metadata, and support subsequent semantic retrieval.
Semantic retrieval: OSS precisely retrieves data based on a combination of natural language descriptions and multiple conditions. This allows you to quickly retrieve destination images and meet retrieval requirements in complex scenarios. Semantic retrieval provides more accurate event matching and reduces manual filtering costs.
Cross-modal retrieval: The intelligent semantic indexing system provides centralized management and cross-modal retrieval capabilities for multi-modal data, such as videos, images, and texts. Relying on OSS and IMM, the intelligent semantic indexing system is an out-of-the-box solution, which significantly reduces the technical threshold and O&M costs.
Flexible scaling: The distributed storage architecture of OSS supports dynamic scaling to easily cope with large amounts of data. Computing resources can be dynamically scaled based on the load to ensure stable system performance.
1. Configure a bucket in which videos are stored
1.1 Create a bucket and upload videos collected from devices
Log on to the OSS console.
In the left-side navigation pane, click Buckets. On the Buckets page, click Create Bucket.
On the Create Bucket page, specify the name of the bucket. We recommend that you use a business-related name, such as
ipc-videos-oss-metaquery-demo. Retain the default settings for other parameters.Click Create. On the page that appears, click Go to Bucket.
On the Objects page, click , select the video objects that you want to upload, such as Video A.mp4, and retain the default settings for other parameters. Click Upload Object.
1.2 Bind an IMM project to the bucket
To use frame capture provided by IMM, you must bind an IMM project to the bucket.
In the left-side navigation pane, choose . On the page that appears, activate IMM and authorize a RAM role, and then click Map Project to Bucket.
In the Map Project dialog box, select Create Project for IMM Configuration, enter the project name in the Project Name field, such as
video-snapshot, and then click OK. The system automatically creates the corresponding IMM project in the region in which the bucket is located and binds the IMM project to the current bucket.
1.3 Create a style for frame capture
Creates a style for frame capture. Frames are captured from a video at a fixed time interval until the video ends, and saved with the original size in the JPG format.
|
|
1.4 Compile code for frame capture
The video object uploaded to the bucket can be captured based on the created style for frame capture. The following sample code provides an example on how to use OSS SDK for Python to perform frame capture.
Prepare the environment
Before you use OSS SDK for Python to perform frame capture, make sure that you have configured the development environment and access credentials. For more information, see Get Started.
2. Configure a bucket to store frames
2.1 Create a bucket
Create a bucket to store frames captured from IP cameras. This way, the video objects and frames are stored in different buckets to optimize data management.
In the left-side navigation pane, click Buckets. On the Buckets page, click Create Bucket.
On the Create Bucket page, specify the name of the bucket. We recommend that you use a business-related name, such as
ipc-frames-oss-metaquery-demo. Retain the default settings for other parameters.Click Create. On the page that appears, click Go to Bucket.
2.2 Enable AISearch for the bucket
Enable AISearch for the bucket. In this case, you can accurately retrieve frames based on natural language descriptions and multiple conditions.
Note The time required to create a metadata index varies based on the number of objects in the bucket. You can refresh the Data Indexing page to check whether AISearch is enabled. |
|
Verify the result
Specify descriptions, such as yard with a car, and frames that match the description are returned.
|
|
Apply the solution to a production environment
The current intelligent semantic indexing system is created. To seamlessly integrate the system into your product and apply it to the production environment, call operations by using the consumer application and use the natural language descriptions to quickly query and retrieve desired frames or video objects.
The following sample code from the consumer application provides an example on how to create an XML MetaQuery request that complies with OSS specifications:
After you run the program, specify a description to query objects. Example: yard with a car. The system returns the results that contain the paths and URLs of the captured frames. You can view the frame details by using the URLs.
Four matching results found:")
Object path: 2025-04-07/Video A/2.jpg
Object URL: https://ipc-frames-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/2025-04-07/%E8%A7%86%E9%A2%91A/2.jpg?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250407T025024Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250407%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=d2d849c56e230f6beaf199ee1ca756bb99b3f6a14ce64c1fa710127149375fac
------------------------
Object path: 2025-04-07/Video C/2.jpg
Object URL: https://ipc-frames-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/2025-04-07/%E8%A7%86%E9%A2%91C/2.jpg?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250407T025024Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250407%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=1b3b456a32f9d0823dcfe5408d156df74e138a194bc06095877e00dd8079511e
------------------------
Object path: 2025-04-07/Video C/1.jpg
Object URL: https://ipc-frames-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/2025-04-07/%E8%A7%86%E9%A2%91C/1.jpg?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250407T025024Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250407%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=1fc66719db2bbe611bc86a63a863d7f94ad9aebf14ccfaff8579938094ace3ef
------------------------
Object path: 2025-04-07/Video A/1.jpg
Object URL: https://ipc-frames-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/2025-04-10/%E8%A7%86%E9%A2%91A/1.jpg?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250407T025024Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250407%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=4dd7f808872b9d4c988efe78a09cb91fd2accbb3e9c12df7cdbdf60bdcc2e7a7
------------------------Learn more
Add tags to a captured frame
To achieve more efficient retrieval, you can use the object tagging feature of OSS to add metadata tags to key frames. For example, you can use tags to identify the source of a video or business scenarios, which allows you to quickly retrieve the target frames in a large number of objects.
If you want to analyze three video objects: Video A.mp4, Video B.mp4, and Video C.mp4.
Video A.mp4 | Video B.mp4 | Video C.mp4 |
|
|
|
Collected from a backyard camera and tagged as Shoot by camera-a. | Collected from a camera in the shop and tagged as Shoot by camera-b. | Collected from a backyard camera and tagged as Shoot by camera-c. |
The following sample code provides an example on how to use OSS SDK for Python to add tags to each video after you upload the video. You only need to modify the tag based on your business requirements to implement automatic tag management, which supports subsequent combined retrieval.
The following sample code from the consumer application provides an example on how to use semantic descriptions and other conditions, such as tags, to perform a combined query to obtain search results:
After you run the intelligent semantic indexing system, to filter video objects whose content is related to "yard with a car", perform the following steps:
Enter the search keywords in the description field:
yard with a carSpecify tag filtering conditions:
camera = camera-a
In the current video objects, both the Video A and the Video C conforms to the description of yard with a car. However, due to tag filtering conditions, only the retrieval objects with the camera-a tag are retained. In this case, only Video A meets all conditions.
Send a DoMetaQuery request.
The request is successful. HTTP status code: 200.
Obtain 4 preliminary matching results from OSS and start client tag filtering...
[1] Object named '2025-04-07/Video A/2.jpg' meets all conditions.
Object URL: https://ipc-frames-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/2025-04-07/%E8%A7%86%E9%A2%91A/2.jpg?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250407T025459Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250407%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=5e9d684ec141f9570f2f95713de492ac8291a39d1d655e4bb4c4d35b40d1e554
Object path: 2025-04-07/Video A/2.jpg
-----------------------
[2] Object named '2025-04-07/Video A/1.jpg' meets all conditions.
Object URL: https://ipc-frames-oss-metaquery-demo.oss-cn-beijing.aliyuncs.com/2025-04-07/%E8%A7%86%E9%A2%91A/1.jpg?x-oss-signature-version=OSS4-HMAC-SHA256&x-oss-date=20250407T025459Z&x-oss-expires=900&x-oss-credential=LTAI********************%2F20250407%2Fcn-beijing%2Foss%2Faliyun_v4_request&x-oss-signature=1c13310abdd764e8ac9f67e27a179f02949eaf47c4ed68358eefcb1965a6dd1e
Object path: 2025-04-07/Video A/1.jpg
-----------------------
Client filtering completed. 2 results found.
Configure an event notification rule for frame capture
In actual applications, frames are captured asynchronously. You cannot obtain the processing results of captured frames directly when the frame capture task is complete. If you want to obtain the processing results of captured frames, we recommend that you use Simple Message Queue (formerly MNS) (SMQ) to configure event notifications. This way, you can receive instant notifications when the frame capture task is complete. You do not need to repeatedly query the task status.
To configure an event notification rule for frame capture, you must create a message topic that is in the same region in which the bucket in which your video objects are stored. For more information, see Get started with topic-based messaging. The following sample code shows how to configure an event notification rule when you capture frames from a video object. The topic name must be Base64-encoded. For example, if the topic name is test-topic, the encoded name is dGVzdC10b3BpYw.





