This topic describes the /green/video/asyncscan operation that you can call to asynchronously moderate videos. You can call this operation to moderate videos for risky or illegal content. This operation is applicable to the following scenarios: pornography detection, terrorist content detection, ad violation detection, undesirable scene detection, logo detection, and audio anti-spam.

Scenarios

Scenario Description Category of the moderation result
Pornography detection Detects pornographic content in a video. normal and porn
Terrorist content detection Detects terrorist content in a video. normal and terrorism
Undesirable scene detection Detects undesirable scenes in a video. normal and live
Logo detection Detects specific logos in a video. normal and logo
Ad violation detection Detects ads or text violations in a video. normal and ad
Audio anti-spam
Note To use this scenario, you must call the /green/video/asyncscan operation to submit asynchronous video moderation tasks. For more information, see Asynchronous moderation.
Detects audio violations in a video.
Note By default, the audio to be moderated must be in Chinese. If you need to moderate audio in English, submit a ticket to contact Alibaba Cloud technical support.
normal, spam, ad, politics, terrorism, abuse, porn, flood, contraband, and customized

Description about the /green/video/asyncscan operation

Operation: /green/video/asyncscan

You can call this operation to submit asynchronous video moderation tasks. For more information about how to construct an HTTP request, see Request structure. You can also select an existing HTTP request. For more information, see SDK overview.

  • Billing method:

    You are charged for calling this operation. For more information about the billing method, seeContent Moderation Pricing.

    If your moderation occurs in multiple scenarios at a time, you are charged the cumulative fee of all scenarios. The fee of each scenario equals the number of video frames that are moderated in the scenario multiplied by the unit price of the scenario. If you moderate the audio in a video at the same time, you are charged an extra fee for audio anti-spam. The extra fee equals the video duration multiplied by the unit price of audio anti-spam.

  • Moderation object:

    You can call this operation to moderate videos or video streams. You can submit a sequence of frames that are captured from a video or a video URL to specify the video to be moderated.

  • Return results:

    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 at regular intervals or enable callback notification. The moderation results are retained for up to 1 hour.

    • Enable callback notification to obtain moderation results: When you submit asynchronous moderation tasks, you can specify a callback URL for receiving moderation results in the callback parameter of the moderation request. For more information about the callback parameter, see Request parameters.
    • Poll moderation results at regular intervals: You do not need to set the callback parameter when you submit asynchronous moderation tasks. After you submit the tasks, you can call the /green/video/results operation to query moderation results. For more information about the operation, see Description about the /green/video/results operation.
  • Limits on videos:
    • The videos must use HTTP or HTTPS URLs.
    • The videos must be in the 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 you have special requirements, for example, you want to moderate larger videos, submit a ticket to raise the threshold.
    • The video streams must be transferred by using the RTMP, HLS, HTTP-FLV, or RTSP protocol.
    • The duration of a video stream moderation task can be up to 24 hours. If the duration exceeds 24 hours, the moderation task automatically ends.
    • 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 Alibaba Cloud Object Storage Service (OSS).

Request parameters

Parameter Type Required Description
bizType String No The business scenario. You can create a business scenario in the Alibaba Cloud Content Moderation console. For more information, see Customize policies for machine-assisted moderation. You can also submit a ticket to ask Alibaba Cloud engineers to help you create a business scenario.
live Boolean No Specifies whether to moderate live streams.

The default value is false, which indicates to moderate videos. To moderate live streams, you must set this parameter to true.

offline Boolean No Specifies whether to enable the nearline moderation mode.
  • The default value is false, which indicates the real-time moderation mode. In this mode, Content Moderation rejects moderation requests that exceed the concurrency limit.
  • If you set this parameter to true, the nearline moderation mode is enabled. In this mode, the moderation tasks you submit may not be processed in real time, but can be queued for processing and will start within 24 hours.
Note This parameter is applicable only to video moderation. This parameter is not required for video stream moderation.
scenes StringArray Yes The video moderation scenario. Valid values:
  • porn: pornography detection
  • terrorism: terrorist content detection
  • live: undesirable scene detection
  • logo: logo detection
  • ad: ad violation detection
audioScenes StringArray No The audio moderation scenario. Set the value to antispam.

If you do not set this parameter, Content Moderation moderates only the images in videos. If you set this parameter, Content Moderation also moderates the audio in a video during video moderation.

Note To moderate the audio in a video, you must set the url parameter in the task parameter to submit the URL of the video or video stream. Audio moderation is inapplicable if you set the frames parameter in the task parameter to submit frames that are captured from a video.
callback String No 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 at regular intervals.
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:
  • checksum: the string in the UID + Seed + Content format that is generated by the Secure Hash Algorithm 256 (SHA-256) algorithm. UID indicates the ID of your Alibaba Cloud account. You can query the ID in the Alibaba Cloud Management Console. To prevent data tampering, you can use the SHA-256 algorithm to generate a string when your server receives a callback notification and verify the string against the received checksum parameter.
    Note UID must be the ID of an Alibaba Cloud account, but not the ID of a RAM user.
  • content: the JSON-formatted string to be parsed to the callback data in the JSON format. For more information about the format of the content parameter, see the sample success responses of each operation that you can call to query asynchronous moderation results.
Note If your server receives a callback notification, the server sends HTTP status code 200 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 for 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 A random string that is used to generate a signature for the callback notification request.

The string can be up to 64 characters in length and can contain letters, digits, and underscores (_). You can customize this string. It is used to verify the callback notification request when Alibaba Cloud Content Moderation pushes callback notifications to your server.

Note This parameter is required if you set the callback parameter.
tasks JSONArray Yes The list of moderation objects. Each element in the JSON array is a structure. For more information about the structure of each element, see task.
Table 1. task
Parameter Type Required Description
clientInfo JSONObject No The information about the client. For more information, see the "Common request parameters" section of the Common parameters topic.
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 The ID of the moderation object.

The ID can contain letters, digits, underscores (_), hyphens (-), and periods (.) and can be up to 128 characters in length. This ID uniquely identifies your business data.

url String No The URL of the video to be moderated. You must set one of the url and frames parameters.
Note If you set this parameter, you are charged for the video moderation task based on the video URL that is submitted.
frames JSONArray No The information about frames that are captured from the video to be moderated. Each element in the JSON array of the frames parameter is a structure. For more information about the structure of each element, see frame.
Note If you set this parameter, you are charged for the video moderation task based on the captured frames that are submitted.
framePrefix String No The prefix of the URL of a captured frame, which is used with frame.url to form the complete URL of a captured frame. The complete URL of a captured frame is in the format of framePrefix + frame.url.
interval Integer No The interval for capturing frames from the video. Unit: seconds. Valid values: 1 to 60. Default value: 1.
maxFrames Integer No The maximum number of frames that can be captured from the video. Valid values: 5 to 3600. Default value: 200. If you need to set this parameter to a greater value, submit a ticket.
Note
  • This parameter is valid only when you set the live parameter to false to moderate videos. If you set the live parameter to true to moderate live streams, the number of frames that can be captured from live streams is not limited.
  • If you use an Object Storage Service (OSS) URL that starts with oss:// as the source URL of a video and authorize Content Moderation to access ApsaraVideo for Media Processing, you can capture a maximum of 20,000 frames from the video. You are not charged extra fees when you use this method. For more information about how to authorize Content Moderation to access ApsaraVideo for Media Processing, see Authorize a role to access ApsaraVideo for Media Processing.
Table 2. frame
Parameter Type Required Description
url String No The URL of the captured frame, which is used with framePrefix to form the complete URL of a captured frame. The complete URL of a captured frame is in the format of framePrefix + frame.url.
offset Integer No The interval between the start of the video and the captured frame. Unit: seconds.

Response parameters

Parameter Type Description
taskId String The ID of the moderation task.
dataId String The ID of the moderation object.
Note If you set the dataId parameter in the moderation request, the dataId parameter is returned in the response.

Examples

Sample requests
  • Moderate frames that are captured from a video
    {
        "scenes": [
            "porn"
        ],
        "tasks": [
            {
                "dataId": "videoId xxx",
                "frames": [
                    {
                        "offset": 10,
                        "url": "http://g1.ykimg.com/0B860000586C0A0300038A0460000"
                    },
                    {
                        "offset": 20,
                        "url": "http://g1.ykimg.com/0B860000586C0A0300038A0460001"
                    },
                    {
                        "offset": 30,
                        "url": "http://g1.ykimg.com/0B860000586C0A0300038A0460002"
                    },
                    {
                        "offset": 40,
                        "url": "http://g1.ykimg.com/0B860000586C0A0300038A0460003"
                    },
                    {
                        "offset": 50,
                        "url": "http://g1.ykimg.com/0B860000586C0A0300038A0460003"
                    },
                    {
                        "offset": 60,
                        "url": "http://g1.ykimg.com/0B860000586C0A0300038A046000x"
                    }
                ]
            }
        ]
    }
  • Moderate a video
    {
         "scenes": [
            "porn"
        ],
         "audioScenes": [
            "antispam"
        ],
         "tasks": [
              {
                   "dataId": "videoId xxx",
                   "url": "http://www.foo.bak/a.mp4",
                   "interval": 1,
                   "maxFrames": 200
            }
        ]
    }
  • Moderate a live stream
    {
        "scenes": [
            "porn"
        ],
        "live": true,
        "tasks": [
            {
                "dataId": "videoId xxx",
                "url": "http://www.foo.bak/a.flv",
                "interval": 1,
                "maxFrames": 200
            }
        ]
    }
Sample success responses
{
    "code": 200,
    "msg": "OK",
    "requestId": "requestID xxx",
    "data": [
        {
            "dataId": "videoId xxx",
            "taskId": "taskId xxx"
        }
    ]
}

Description about the /green/video/results operation

Operation: /green/video/results

You can call this operation to query asynchronous video moderation results. For more information about how to construct an HTTP request, see Request structure. You can also select an existing HTTP request. For more information, see SDK overview.

  • Billing method:

    This operation is free of charge.

  • Response timeout:

    We recommend that you query moderation results at least 30s after you send an asynchronous moderation request. Content Moderation retains moderation results for up to 4 hours. If you query moderation results after 4 hours, the results are deleted.

Request parameters

Parameter Type Required Description
body JSONArray Yes The list of IDs of asynchronous moderation tasks that you want to query. The array can contain up to 100 elements.

Response parameters

Parameter Type Description
code Integer The returned HTTP status code.

For more information, see Common response parameters.

msg String The returned message.
dataId String The ID of the moderation object.
Note If you set the dataId parameter in the moderation request, the dataId parameter is returned in the response.
taskId String The ID of the moderation task.
results JSONArray The return results. If HTTP status code 200 is returned after a successful call, the array in the return results contains one or more elements. Each element is a structure. For more information about the structure of each element, see result.
Note In the scenario of moderating a video stream, HTTP status code 280 indicates that the moderation task is in progress, and HTTP status code 200 indicates that the moderation task is completed. If the moderation task is in progress, the returned moderation results contain all the issues that Content Moderation has detected in the task.
audioScanResults JSONObject The audio moderation results. For more information about the structure, see audioScanResult.
Table 3. result
Parameter Type Description
scene String The moderation scenario of the moderated video, which you specify in the moderation request. Valid values:
  • porn: pornography detection
  • terrorism: terrorist content detection
  • live: undesirable scene detection
  • logo: logo detection
  • ad: ad violation detection
label String The category of the moderation result of the moderated video. Valid values vary based on the specified moderation scenario.
  • If the scenes parameter is set to porn, the valid values are:
    • normal: normal
    • porn: pornographic content
  • If the scenes parameter is set to terrorism, the valid values are:
    • normal: normal
    • terrorism: terrorist content
  • If the scenes parameter is set to live, the valid values are:
    • normal: normal
    • live: undesirable scene
  • If the scenes parameter is set to logo, the valid values are:
    • normal: normal
    • logo: logo
  • If the scenes parameter is set to ad, the valid values are:
    • normal: normal
    • ad: ad or text violation
sublabel String If the scenes parameter is set to porn or terrorism, the subcategory of the moderation result can be returned.

By default, this parameter is not returned. If you want this parameter to be returned, submit a ticket. This parameter can be returned only after it is configured by Alibaba Cloud engineers.

suggestion String The recommended subsequent operation for you to perform. Valid values:
  • pass: The moderation object does not require further actions.
  • review: The moderation object contains suspected violations and requires human review.
  • block: The moderation object contains violations. We recommend that you delete or block the object.
rate Float The score of the confidence level. Valid values: 0 to 100. A greater value indicates a higher confidence level.
If a value of pass is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content is normal. If a value of review or block is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content contains violations.
Notice This score is for reference only. We strongly recommend that you do not use this score in your business. We recommend that you use the values that are returned for the suggestion, label, and sublabel parameters to determine whether the content contains violations. The sublabel parameter is returned by specific operations.
frames JSONArray The moderation results of captured frames. For more information about the structure, see frame.
extras JSONObject The additional information.

If you specify ad in the scenes parameter to detect ad violations, the extras parameter can return the following content:

hitLibInfo: the information about the custom text library that the detected text in the moderated video hits. For more information about the structure, see hitLibInfo.

Example:
"hitLibInfo":[{"context":"Haokan","libCode":"2144002","libName":"Text pattern library a"}]
hintWordsInfo JSONArray The information about the term that the detected ad or illegal text in the moderated video hits. For more information about the structure, see hintWordsInfo.
Note This parameter is applicable only to ad violation detection.
Example:
"hintWordsInfo":[{"context":"Sensitive words"}]
logoData JSONArray The information about the detected logo in the moderated video. For more information about the structure, see logoData.
Note This parameter is applicable only to logo detection.
sfaceData JSONArray The information about the detected terrorist content in the moderated video. For more information about the structure, see sfaceData.
Note This parameter is applicable only to terrorist content detection.
Table 4. frame
Parameter Type Description
url String The URL of the captured frame.
offset Integer The interval between the start of the video and the captured frame. Unit: seconds.
label String The category of the moderation result of the captured frame. Valid values vary based on the specified moderation scenario.
  • If the scenes parameter is set to porn, the valid values are:
    • normal: normal
    • sexy: sexy content
    • porn: pornographic content
  • If the scenes parameter is set to terrorism, the valid values are:
    • normal: normal
    • bloody: bloody content
    • explosion: explosion and smoke
    • outfit: special costume
    • logo: logo
    • weapon: weapon
    • politics: political content
    • violence: violence
    • crowd: crowd
    • parade: parade
    • carcrash: car accident
    • flag: flag
    • location: landmark
    • others: other specified content
  • If the scenes parameter is set to ad, the valid values are:
    • normal: normal
    • politics: political content in text
    • porn: pornographic content in text
    • abuse: abuse in text
    • terrorism: terrorist content in text
    • contraband: prohibited content in text
    • spam: junk content in text
    • npx: illegal ad
    • qrcode: QR code
    • programCode: mini program code
    • ad: other ads
    Note By default, only normal and ad can be returned. If you want to use other categories, submit a ticket.
  • If the scenes parameter is set to live, the valid values are:
    • normal: normal
    • meaningless: meaningless, such as black or white screen
    • PIP: small picture
    • smoking: smoking content
    • drivelive: live broadcasting in a running vehicle
  • If the scenes parameter is set to logo, the valid values are:
    • normal: normal
    • TV: TV station logo
    • trademark: trademark
rate Float The score of the confidence level. Valid values: 0 to 100. A higher confidence level indicates higher reliability of the moderation result. We recommend that you do not use this score in your business.
Table 5. audioScanResult
Parameter Type Description
audioScene String The audio moderation scenario of the moderated video. The value is fixed to antispam.
label String The category of the audio moderation result for the moderated video. Valid values vary based on the specified moderation scenario.
  • normal: normal
  • spam: junk content
  • ad: ad
  • politics: political content
  • terrorism: terrorist content
  • abuse: abuse
  • porn: pornographic content
  • flood: excessive junk content
  • contraband: prohibited content
  • customized: custom content, such as a custom term
suggestion String The recommended subsequent operation for you to perform. Valid values:
  • pass: The moderation object does not require further actions.
  • review: The moderation object contains suspected violations and requires human review.
  • block: The moderation object contains violations. We recommend that you delete or block the object.
rate Float The score of the confidence level. Valid values: 0 to 100. A greater value indicates a higher confidence level.
If a value of pass is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content is normal. If a value of review or block is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content contains violations.
Notice This score is for reference only. We strongly recommend that you do not use this score in your business. We recommend that you use the values that are returned for the suggestion, label, and sublabel parameters to determine whether the content contains violations. The sublabel parameter is returned by specific operations.
details JSONArray The details about text in the moderated audio. The JSON array contains one or more elements. Each element corresponds to a text entry. For more information, see detail.
Table 6. detail
Parameter Type Description
startTime Integer The start time of the text entry. Unit: seconds.
endTime Integer The end time of the text entry. Unit: seconds.
text String The content of the text entry that is converted from the audio.
label String The category of the moderation result of the text entry. Valid values:
  • normal: normal
  • spam: junk content
  • ad: ad
  • politics: political content
  • terrorism: terrorist content
  • abuse: abuse
  • porn: pornographic content
  • flood: excessive junk content
  • contraband: prohibited content
  • customized: custom content, such as a custom term
keyword String The custom term that the text entry hits.
libName String The name of the custom text library that contains the custom term hit by the text entry.
Table 7. logoData
Parameter Type Description
type String The type of the detected logo. For example, a value of TV indicates the logo of a TV station.
name String The name of the detected logo.
x Float The distance between the upper-left corner of the logo area and the y-axis, with the upper-left corner of the image being the coordinate origin. Unit: pixels.
y Float The distance between the upper-left corner of the logo area and the x-axis, with the upper-left corner of the image being the coordinate origin. Unit: pixels.
w Float The width of the logo area. Unit: pixels.
h Float The height of the logo area. Unit: pixels.
Table 8. sfaceData
Parameter Type Description
x Float The distance between the upper-left corner of the face area and the y-axis, with the upper-left corner of the image being the coordinate origin. Unit: pixels.
y Float The distance between the upper-left corner of the face area and the x-axis, with the upper-left corner of the image being the coordinate origin. Unit: pixels.
w Float The width of the face area. Unit: pixels.
h Float The height of the face area. Unit: pixels.
faces JSONArray The information about the recognized face. The array contains the following parameters:
  • name: the name of the recognized face. The value is a string.
  • rate: the score of the confidence level. Valid values: 0 to 100. A greater value indicates a higher confidence level. A higher confidence level indicates higher reliability of the facial recognition result. The value is a floating-point number.
  • id: the ID of the recognized face. The value is a string.
Table 9. hitLibInfo
Parameter Type Description
context String The custom text that the detected text hits.
libCode String The code of the library that contains the custom text hit by the detected text.
libName String The name of the library that contains the custom text hit by the detected text.
Table 10. hintWordsInfo
Parameter Type Description
context String The term that the detected text hits.

Examples

Sample requests
[
    "taskId xxx",
    "taskId bbb"
]
Sample success responses
  • Detect only the images in a video
    {
        "code": 200,
        "msg": "OK",
        "requestId": "requestID xxx",
        "data": [
            {
                "code": 200,
                "msg": "OK",
                "dataId": "videoId xxx",
                "taskId": "taskId xxx",
                "results": [
                    {
                        "label": "porn",
                        "rate": 99.2,
                        "scene": "porn",
                        "suggestion": "block"
                    }
                ]
            }
        ]
    }
  • Detect both the images and audio in a video
    {
        "code": 200,
        "msg": "OK",
        "requestId": "requestID xxx",
        "data": [
            {
                "code": 200,
                "msg": "OK",
                "dataId": "videoId xxx",
                "taskId": "taskId xxx",
                "results": [
                    {
                        "label": "porn",
                        "rate": 99.2,
                        "scene": "porn",
                        "suggestion": "block"
                    }
                ],
                "audioScanResults": [
                    {
                        "audioScene": "antispam",
                        "label": "customized",
                        "suggestion": "block",
                        "rate": 99.91,
                        "details": [
                            {
                                "startTime": 0,
                                "endTime": 24,
                                "text": "blabla...",
                                "label": "customized"
                            },
                            {
                                "startTime": 24,
                                "endTime": 60,
                                "text": "blabla...",
                                "label": "normal"
                            }
                        ]
                    }
                ]
            }
        ]
    }