This topic describes how to call the asynchronous video quality detection operation (/green/video/asyncscan) to detect video quality. This information helps you construct HTTP requests.
Usage notes
API operation: /green/video/asyncscan
This operation asynchronously detects quality issues in video files, such as blur, splicing, low brightness, black screens, and static frames. For more information about how to construct an HTTP request, see Request structure. To use a pre-built HTTP request, see SDK overview.
- Billing information
You are charged for calling this operation. For more information about the billing methods, see
- Detection scenarios
This scenario supports only standalone video quality detection and cannot be used with other scenarios. Audio content detection is not supported.
- Response
If you send asynchronous moderation requests, the moderation results are not returned in real time. To obtain moderation results, you can poll the moderation results periodically or enable callback notification. The moderation results are retained for up to 1 hour.
- callback parameter: To automatically receive detection results, include the callback parameter in the request when you submit an asynchronous detection task. For more information, see Request parameters.
- Retrieve detection results by polling: If you do not include the callback parameter when you submit the task, you must poll for the results. After the task is submitted, call the result query operation to retrieve the detection results. For more information, see Usage notes (Query asynchronous video detection results).
- Video requirementsThe video to be detected must meet the following requirements:
The URLs of videos must be HTTP or HTTPS URLs.
The videos must be in AVI, FLV, MP4, MPG, ASF, WMV, MOV, WMA, RMVB, RM, FLASH, or TS format.
A video can be up to 200 MB in size.
If the video to be moderated exceeds 200 MB, the video must be segmented. You can join the DingTalk Group (DingTalk Group number: 35573806) and contact the technical support personnel to help you adjust the size limit.
The duration of a video moderation task varies based on the duration for downloading the video. Make sure that you use a stable and reliable storage service to store the videos to be moderated. We recommend that you use Object Storage Service (OSS).
QPS limits
You can call this operation up to 50 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
Request parameters
| Name | Type | Required | Example | Description |
| bizType | String | No | default | The business scenario. You can create a business scenario in the Content Moderation console. For more information, see Customize policies for machine-assisted moderation. |
| scenes | StringArray | Yes | ["quality"] | The scenarios for video detection. The only valid value is quality, which indicates video quality detection. |
| callback | String | No | http://www.aliyundoc.com/xx.json | The callback URL for notifying you of asynchronous moderation results. HTTP and HTTPS URLs are supported. If you do not set this parameter, you must poll moderation results periodically. If you set the callback parameter in the moderation request, make sure that the specified HTTP or HTTPS URL meets the following requirements: supports the POST method, uses UTF-8 to encode the transmitted data, and supports the checksum and content parameters. To send moderation results to the specified callback URL, Content Moderation returns the checksum and content parameters in callback notifications based on the following rules and format:
Note If your server successfully receives a callback notification, the server sends an HTTP 200 status code to Content Moderation. If your server fails to receive a callback notification, the server sends other HTTP status codes to Content Moderation. If your server fails to receive a callback notification, Content Moderation continues to push the callback notification until your server receives it. Content Moderation can push a callback notification repeatedly up to 16 times. After 16 times, Content Moderation stops pushing the callback notification. In this case, we recommend that you check the status of the callback URL. |
| seed | String | No | aabbcc123 | This value is used for the signature in the callback notification request. This parameter is required when you use the callback parameter. |
cryptType | String | No | SHA256 | The encryption algorithm used to encrypt the callback notification content when you enable callback notification. Content Moderation encrypts the returned string by using the encryption algorithm that you specify and sends the encrypted string to the callback URL. The returned string is in the UID + Seed + Content format. Valid values:
|
| tasks | JSONArray | Yes | The detection objects. Each element in the JSON array is a detection task struct. You can specify up to 100 elements, which means you can submit 100 pieces of content for detection at a time. To support 100 elements, you must adjust the number of concurrent tasks to 100 or more. For more information about the structure of each element, see task. |
| Name | Type | Required | Example | Description |
| clientInfo | JSON object | No | {"userId":"120234234","userNick":"Mike","userType":"others"} | The information about the client. For more information, see the "Common request parameters" section of Common parameters. The server determines whether to use the global clientInfo parameter or the clientInfo parameter that is described in this table. Note The clientInfo parameter in this table takes priority over the global one. |
| dataId | String | No | videoId xxx | The data ID. Make sure that all IDs in a single request are unique. |
| url | String | No | http://www.aliyundoc.com/a.mp4 | The public URL of the video. The URL must be accessible from the Internet. |
| interval | Integer | No | 1 | The interval for video snapshots, in seconds. Valid values: 1 to 600. Default value: 1. |
| maxFrames | Integer | No | 200 | The maximum number of frames that the system can capture from the video for this detection. Valid values: 5 to 3600. Default value: 200. To increase the limit, contact your account manager. Note If you use an OSS URL (starting with oss://) as the video source and authorize Content Moderation to access Alibaba Cloud ApsaraVideo Media Processing (MTS), you can capture up to 20,000 frames. This does not incur additional fees. For more information about how to authorize Content Moderation to access MTS, see Authorize access to MTS. |
{
"code": 200,
"msg": "OK",
"dataId": "videoId xxx",
"taskId": "taskId xxx",
"results": [
{
"label": "normal",
"rate": 99.2,
"scene": "quality",
"suggestion": "pass"
}
]
}Response data
| Name | Type | Example | Description |
| taskId | String | taskId xxx | The ID of the detection task. |
| dataId | String | videoId xxx | The ID of the moderation object. Note If you set the dataId parameter in the moderation request, the value of the dataId request parameter is returned here. |
Examples
http(s)://[Endpoint]/green/video/asyncscan
&<Common request parameters>
{
"scenes": [
"quality"
],
"tasks": [
{
"dataId": "videoId xxx",
"url": "http://www.aliyundoc.com/a.mp4",
"interval": 1,
"maxFrames": 200
}
]
}{
"code": 200,
"msg": "OK",
"requestId": "requestID xxx",
"data": [
{
"dataId": "videoId xxx",
"taskId": "taskId xxx"
}
]
}Usage notes (Query asynchronous video detection results)
API operation: /green/video/results
This operation queries the results of an asynchronous detection task. The recommended query interval is 30 seconds. The maximum interval is 4 hours. If you query for results after this period, the results might be lost.
This operation is free of charge.
QPS limits
You can call this operation up to 50 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
Request parameters
| Name | Type | Required | Example | Description |
| body | JSONArray | Yes | ["taskId xxx","taskId bbb"] | A list of taskId values to query. The maximum length is 100. |
Response data
| Name | Type | Example | Description |
| code | Integer | 200 | The returned HTTP status code. For more information, see Common error codes. |
| msg | String | OK | The response message for the request. |
| dataId | String | videoId xxx | The ID of the moderation object. Note If you set the dataId parameter in the moderation request, the value of the dataId request parameter is returned here. |
| taskId | String | taskId xxx | The ID of the detection task. |
| results | JSONArray | The returned results. When the call is successful (code=200), the response contains one or more elements. Each element is a struct. For more information about the structure, see result. Note In stream pulling detection scenarios, a `code` of 280 indicates that the detection is in progress, and 200 indicates that the detection is complete. When the detection is in progress, the results include issues detected from the start of the detection to the current time. |
| Name | Type | Example | Description |
| scene | String | quality | The video detection scenario. This corresponds to the scenario in the request. |
| label | String | static | The classification of the detection result, which corresponds to the specific scene. Valid values:
|
| suggestion | String | block | The recommended action. Valid values:
|
| rate | Float | 99.2 | The probability that the result belongs to this classification. Valid values: 0 to 100. A higher value indicates a higher probability. |
| frames | JSONArray | The detection results for some frames that are classified into this category (FrameScanResult). Each element is a struct. For more information about the structure, see frame. |
| Name | Type | Example | Description |
| url | String | http://www.aliyundoc.com | The URL of the snapshot. If content with quality issues is found in the video, the URL of the snapshot is returned. |
| offset | Integer | 2 | The timestamp of this snapshot relative to the beginning of the video, in seconds. |
| label | String | static | The threat classification of this video snapshot. Valid values:
|
| rate | Float | 99.2 | The probability that this video snapshot result belongs to the classification specified by label. Valid values: 0 to 100. A higher value indicates a higher probability. |
Examples
http(s)://[Endpoint]/green/video/results
&<Common request parameters>
[
"taskId xxx",
"taskId bbb"
]{
"code": 200,
"msg": "OK",
"requestId": "requestID xxx",
"data": [
{
"code": 200,
"msg": "OK",
"dataId": "videoId xxx",
"taskId": "taskId xxx",
"results": [
{
"label": "static",
"rate": 99.2,
"scene": "quality",
"suggestion": "block"
}
]
}
]
}