Real-Time Stream Moderation

Live stream pulling moderation aims to detect malicious information in real-time audio/video streams, and give the control suggestions for the moderation result. The detection method is to extract frames from video streams periodically, detect malicious information in frame pictures, and recognize periodic segments of audio streams. Currently, this method supports recognizing video and audio streams.

1. Introduction

The caller submits real-time audio/video streams to be detected, and specifies the detection type. The server periodically extracts and clips frames to detect the returned detection result of callback.

The detection types supported by Video Stream moderation and corresponding labels are as follows:

Detection Type Description Action Primary Label Secondary Label
Porn recognition Recognize porn and sexy contents in pictures v-porn
normal: normal normal: normal
sexy: sexy female_underwear: female underwear
female_sexy_chest_l12: female sexy chest level 12
female_sexy_chest_l3: female sexy chest level 3
female_sexy_chest_l4: female sexy chest level 4
female_backless: female backless
female_sexy_leg: female sexy leg
female_focus_leg: female focus leg
bathing_suit: bathing suit
male_topless: male topless
male_normal_topless: male normal topless
other_sexy: other sexy
porn: porn sex_product: sex aids
naked_private_part: exposed sensitive parts
extensive_naked: extensive naked
sex_behavior: sex behavior
naked_female_back: naked famale back
naked_hip: naked hip
sex_bulge: sex bulge
focus_female_crotch: focus female crotch
focus_male_crotch: focus male crotch
hand_on_sexy: hand on sexy
lick: lick
kiss: kiss
sm: SM
sperm: sperm
naked_child: naked child
other_dirty: other dirty
tongue_out: tongue out
female_focus_hip: female focus hip
male_underwear: male underwear
porn_pip: porn pip
Terrorism recognition Recognize bloody and terrorism contents in pictures v-terrorism normal: normal
fire_explosion: fire explosion
gun: gun
knife: knife
crowd: crowd
flag_of_terrorism: flag of terrorism
special_dress: special dress
disgusted: disgusted
with_weapon: with weapon
bloody: bloody
uniform: uniform
nil
Sensitive information recognition Recognize sensitive contents in pictures v-antispam normal: normal
special_building: special building
rmb: RMB
map_of_China: map of China
cartoons_of_leaders: cartoons of leaders
flags_of_China: flags of China
Tibetan_buddhism: Tibetan buddhism
other_antispam: Other sensitive information
tank: tank
fighter: fighter
cannon: cannon
battleship: battleship
nil
Sensitive figure recognition Recognize domestic and overseas politicians, and public figures in pictures v-sface normal: normal
sface: sensitive figure involved
nil
Illegal recognition Identify whether the picture contains illegal scene information v-illegal normal: normal
minor: minor
drug: drug
drive: drive
gamble: gamble
smoke: smoke
id_infomation: id infomation
tattoo: tattoo
inbed: lie on the bed
nil
AD recognition Identify whether the image contains advertising information v-ad normal: normal
QR_code: QR code
bar_code: bar code
applet_code: applet code
nil
OCR recognition Identify whether the picture contains suspected violation text information v-ocr normal: normal
ocr_politics: politics
ocr_terrorism: terrorism
ocr_porn: porn
ocr_illegal: illegal
ocr_abuse: abuse
ocr_ad: ad
nil

The Audio Stream supported detection types and corresponding labels are as follows:

Detection TypeDescriptionActionLabel
Moan recognitionDetect voiceprint features in audio files, and recognize illegal features, such as moana-pornnormal: normal
moan: moan
Sensitive word recognitionTranslate the text of audio files, and recognize sensitive and illegal contentsa-antispamnormal: normal
terrorism: terrorism
porn: porn
illegal: illegal
politics: politically sensitive contents
abuse: abuse
ad: advertisement cheating
feudalism: feudalism
religion: religiously sensitive contents
affairs: affairs
contraband: contraband
minors: minors
banned-website: banned websites
Automatic speech recognitionTranslate the text of audio filesa-asrnormal: normal

2. Restrictions

Restriction CategoryDescription
Video stream protocolRTMP; for more live streaming modes, please contact the technical support.
Screenshot intervalScreenshot every 2 seconds
Saving durationThe system will automatically save suspected illegal screenshots and audio clips, and return the file URL and detection result to the user.
These files will be kept for 3 hours. Their URLs may become invalid over 3 hours. Please export the files in time.
Video resolutionAt least 128 x 128. The extra-low resolution may affect the recognition effect.
Duration limitThe detection task for a single video stream can last up to 24 hours.
Concurrency restrictionFor each user, the number of real-time stream detection tasks concurrently running does not exceed 200 by default. For higher concurrency capabilities, please contact the technical support.
Stream pulling timeoutIn the event that the live streaming stops or the stream pulling keeps failing for over 5 minutes due to other reasons, the task will stop automatically, and the event will be returned to the service side, which will determine whether to launch the task request again.
Area restrictionOnly in Chinese mainland. For support in other countries and regions, please contact the technical support.

3. API

3.1 Start the Task

Initiate A Request

ItemDescription
Request methodPOST
Request protocol HTTPS
Request domain nameai.jocloud.com
Request pathapp/{appId}/v1/video/live/start?traceId=xxxxx
Request parameterstraceId is a uuid string, and used for problem positioning during troubleshooting. It is suggested to use different values for each request.
Request headerContent-Type: application/json;charset=UTF-8
token:Authentication token; for its generation mode, see Identity Authentication
Request bodyjson character string, defined as follows

Request Content

NameTypeRequiredDescription
actionsString arrayYesVideo detection type. Options include:
v-porn: Porn recognition
v-terrorism: terrorism recognition
v-antispam: Sensitive information recognition
v-sface: Sensitive figure recognition
v-illegal: illegal recognition
v-ad: ad information recognition
v-ocr: ocr information recognition

Audio detection type. Options include:
a-porn: moan recognition
a-antispam: Sensitive word recognition
a-asr: automatic speech recognition
urlStringYesAddress of video stream to be detected
streamIdStringNoUnique identifier of detected streams
contextJSONNoUser-defined context data, automatically provided during result returning and callback.
statusCbStringNoThe callback result of abnormal task status, such as stream pulling failure, timeout stop, and user stop.
resultCbStringNourl http for callback of detection result. This field can be empty. When it is empty, the service needs to call the search API to obtain the detection result.
resultCbLevelStringNoResult callback level control, you can use one of the following:
- pass: all audit results will be called back
- review: will call back only when review and block results are identified
- block: It will call back when the block result is recognized.
The default is 'pass', all results are called back
sequenceStringNoThis value is used for the signature in the callback notification request. This field is mandatory for callback. See result callback description for detailed use method.
extraJSONNoextra info, as follow

Table. extra

NameTypeDescription
langStringLanguage of the audio clip when action is 'a-antispam'.
- chinese: Chinese
- bahasa: Bahasa Indonesia
use chinese as default.

Response Parameters

The data in the respond message body of starting command is JSON, and the specific field is described as below:

NameTypeRequiredDescription
codeIntegerYesError code, Error code in request
messageStringYesDescription of error message
traceIdStringYesMap to traceId in the request parameter
streamIdStringNoMap to streamId in the request parameter
taskIdStringYesA unique task identifier generated by the system specific to this detection request, serving as the identifier for subsequent result callback and detection stopping.
contextJSONNoMap to context in the request
timestampIntegerYesCurrent unix timestamp, in units of second

3.2 Call Back the Result

Callback Time

  1. When detecting that the real-time stream contains any illegal information, call the resultCb provided address and notify the user of the detection result;
  2. When an exception occurs to the detection task, such as stream pulling failure and decoding failure, call the statusCb provided address and notify the user of the task status.
  • Fields resultCb and statusCb in a starting task can be empty. If they are empty, you can obtain the task status and result through the search APIs.
  • If you obtain the result and task status with callback, the callback of HTTP service must run stably.
  • When access to the callback address fails or the returned status code is not 200, the Jocloud background allows At Most 5 Retries .

Callback Method

Access user provided URL by HTTPS POST method, and fill the status and result in the http request body in JSON string format. See the next section for the specific format.
To prevent content tampering, add a checksum item to the header of http request, to verify content validity.

The checksum string is generated by the following method:

The sequence + body string data contained in parameters of the starting task generate the checksum value through the SHA256 algorithm.

Recognition Result Callback

NameTypeRequiredDescription
streamIdStringNoStream identifier, mapping to the detection stream ID in the starting task
taskIdStringYesTask ID, mapping to the taskId field returned by the starting task
contextJSONNoUser context, mapping to the context in the starting task
statusStringYesTask status (running - in running, stopped - normal stop, error - error occurred)
timestampIntegerYesCurrent unix timestamp of server, in units of second
results[]ArrayNoReturn the result data. The return result contains one or more results. Array elements are defined in the "result" table below.

Table: result

NameTypeRequiredDescription
codeIntegerYesError code, Error code in data and action
messageStringYesDescription of errors
actionStringYesDetection type, mapping to the detection type (actions) in the call request
labelStringYesDetection result label; its value is related to action. For specific values, see above moderation types and corresponding label specification table.
rateFloating-point numberYesProbability of detection result label, with the value ranging between [0.00 – 1.00]. The greater the value, the higher the credibility.
suggestionStringYesOperation recommended, with the value options:
- pass: normal, no operation needed;
- review: suspected, detection result uncertain, requiring further manual moderation
- block: illegal, suggested to give punishment
URLStringNoAddress of saving video screenshots or voice clips corresponding to the recognition result (Notes: These files will be kept for 3 hours. Their URLs may become invalid over 3 hours. Please export the files in time.)
textStringNoText content of audio clips, provided only when action is "a-antispam" or "a-asr".
extraData[]JSON arrayNoAdditional information for the return result. Not all detection types have additional information, and the return structure varies for different detection types. See the following descriptions for detailed definition.
When action is v-porn, use v-porn extraData
When action is v-sface, use v-sface extraData
When action is a-porn, use a-porn extraData
When action is a-antispam, use a-antispam extraData

Table: v-porn-ExtraData

NameTypeRequiredDescription
labelStringYesDetected secondary label
rateFloating-point numberYesProbability of detection result label, with the value ranging between [0.00 – 1.00]. The greater the value, the higher the credibility.

Table: v-sface-ExtraData

NameTypeRequiredDescription
labelStringYesDetected face label
rateFloating-point numberYesProbability of detection result label, with the value ranging between [0.00 – 1.00]. The greater the value, the higher the credibility.
nameStringYesDetected name of sensitive figure
xIntegerYesX-coordinate of the upper left corner of the detected face in the picture
yIntegerYesY-coordinate of the upper left corner of the detected face in the picture
wIntegerYesWidth of detected face
hIntegerYesHeight of detected face

Table: a-porn-extraData

NameTypeRequiredDescription
beginFloating-point numberNoStart time of audio clip (in second)
endFloating-point numberNoEnd time of audio clip (in second)
scoreFloating-point numberNoMatching degree of moan, value ranging between: [0–100]. The higher the score, the higher the matching degree.

Table: a-antispam-extraData

NameTypeRequiredDescription
hintJson arrayNoHit keyword
labelStringNoType of hit keyword
rateFloating-point numberNoMeaningless, always "1.0"

Recognition Status Callback

NameTypeRequiredDescription
streamIdStringNoStream identifier, mapping to the detection stream ID in the starting task
taskIdStringYesTask ID, mapping to the taskId field returned by the starting task
contextJSONNoUser context, mapping to the context in the starting task
statusStringYesTask status (running - in running, stopped - normal stop, error - error occurred)
errCodeIntegerYesError code
100 - the task stops due to stream pulling failure and timeout
101 - the stream pulling fails and retries automatically before timeout (not indicating the task stop)
errMessageStringYesDescription of error reasons
timestampIntegerYesCurrent unix timestamp of server, in units of second

3.3 Search Results

Request Method

ItemDescription
Request MethodPOST
Request protocol HTTPS
Request domain nameai.jocloud.com
Request pathapp/{appid}/v1/video/live/results?traceId=xxxx-xxxx-xxxx-xxxx&taskId=yyyy
Request parameterstraceId is a uid string, used for problem positioning during troubleshooting. It is suggested to use different values for each request.
taskId is the task ID to be searched, mapping to the taskId included in respon during task starting.
Request headerContent-Type: application/json;charset=UTF-8
token: Authentication token; for its generation mode, see Identity Authentication

Returned Contents

NameTypeRequiredDescription
codeIntegerYesError code, Error code in request
messageStringYesDescription of error message
traceIdStringYestraceId content in the pass-through request parameter
taskIdStringYestaskId for this search, consistent with the request parameter
streamIdStringNoStream ID, mapping to streamId in the starting task parameters
contextStringNoUser context, mapping to context in the starting task parameters
statusStringYesTask status (running - in running, stopped - normal stop, error - error occurred)
errCodeIntegerYesError code
errMessageStringYesError reasons
timestampIntegerYesCurrent unix timestamp (s)
results[]results arrayNoStore recent multiple result data. When the call succeeds (code==200), each element in the array is of the structure as shown in Table 2 "results" below.

Table 2 Results

NameTypeRequiredDescription
timestampIntegerYesTime of getting the recognition result (unix timestamp, in units of second)
result[]result arrayNoStore multiple result data of action recognition. Each element in the array is of the structure as shown in Table 1 "result".

3.4 Stop the Detection Task

Request Method

ItemDescription
Request methodPOST
Request protocol HTTPS
Request domain nameai.jocloud.com
Request pathapp/{appid}/v1/video/live/stop?traceId=xxxx-xxxx-xxxx-xxxx&taskId=yyyy
Request parameterstraceId is a uuid string, used for problem positioning during troubleshooting. It is suggested to use different values for each request.
taskId is the task ID to be searched, mapping to the taskId included in respon during task starting.
Request headerContent-Type: application/json;charset=UTF-8
token: Authentication token; for its generation mode, see Identity Authentication

Return Parameters

Data in return body is JSON. The specific field is described below:

NameTypeRequiredDescription
codeIntegerYesError code, Error code in request
messageStringYesDescription of error message
traceIdStringYesMap to traceId content in the request parameter
taskIdStringYesMap to taskId in the request parameter
timestampIntegerYesCurrent unix timestamp of server, in units of second

4. Sample Code

The following demonstrates the calling process with python code

4.1 Request to Start the Task

# -*- coding: utf-8 -*-
#! python3.5

import requests
import uuid
import base64

host = "https://ai.jocloud.com"

appid = 1234567890  # Your Service id
restful_id = '**********'  # Your certificate ID
restful_secret = '**********'  # Your certificate key
traceid = str(uuid.uuid4())
dataid = str(uuid.uuid4())

# url
url = host + '/app/%s/v1/video/live/start?traceId=%s' % (appid, traceid)

# headers
headers = {
    "content-type": "application/json"
}

auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + auth.decode()

# Live streaming stream address to be identified
streamurl = 'rtmp://mytest.com/live/123456789'

# Context information to be used by the service to assist the subsequent treatment in the callback message, for example: 
context = {
    'myid': 123,
    'myname': 'test'
}

# Identification result and callback address of status, and the identification result and status notificafication are called back through http POST
resultCb = 'http://192.168.1.100:12345/result'
statusCb = 'http://192.168.1.100:12345/status'

# content
values = {
    'actions': ['v-porn'],
    'url': streamurl,
    'streamId': "demo-test",
    'resultCb': resultCb,
    'statusCb': statusCb,
    'sequence': 'test',
    'context': context
}

# request
res = requests.post(url, json=values, headers=headers)
print ('code=%s, data=%s\n' % (res.status_code, res.text))

The call results are returned as follows:

{
    "code": 200,
    "message": "OK",
    "traceId": "f35a8abb-db6c-48f2-af7e-f6c0921b7b0d",
    "taskId": "acee5522-b198-4325-9434-61b41eb2e08a",
    "timestamp": 1576567090,
    "streamId": "demo-test",
    "context": {
        "myid": 123,
        "myname": "test"
    }
}
# -*- coding: utf-8 -*-
#! python3.5

import requests
import uuid
import base64

host = "https://ai.jocloud.com"

appid = 1234567890  # Your Service ID
restful_id = '**********'  # Your certificate ID
restful_secret = '**********'  # Your certificate key
task_id = "acee5522-b198-4325-9434-61b41eb2e08a"  # Fill in the taskId content returned when starting the task here

traceid = str(uuid.uuid4())
dataid = str(uuid.uuid4())

# url
url = host + '/app/%s/v1/video/live/results?traceId=%s&taskId=%s' % (appid, traceid, task_id)

# headers
headers = {
    "content-type": "application/json"
}

auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + auth.decode()

# request
res = requests.get(url, headers=headers)
print ('url=%s\ncode=%s\ndata=%s\n' % (url, res.status_code, res.text))

The call results are returned as follows:

{
    "code": 200,
    "message": "OK",
    "traceId": "fe0a8278-0ed6-4c74-80ab-fb1066605227",
    "taskId": "acee5522-b198-4325-9434-61b41eb2e08a",
    "timestamp": 1576567239,
    "streamId": "demo-test",
    "context": {
        "myid": 123,
        "myname": "test"
    },
    "results": [
        {
            "result": [
                {
                    "action": "v-porn",
                    "label": "normal",
                    "rate": 0.99952548742294312,
                    "suggestion": "pass",
                    "timestamp": 1576567232,
                    "url": "http://jocloud-ai-openapi.oss-cn-hangzhou.aliyuncs.com/live/10034/cccc2dcc-5472-4fbf-ae1b-5a906ea46c46.jpg"
                }
            ],
            "timestamp": 1576567233
        },
        {
            "result": [
                {
                    "action": "v-porn",
                    "label": "normal",
                    "rate": 0.99910759925842285,
                    "suggestion": "pass",
                    "timestamp": 1576567227,
                    "url": "http://jocloud-ai-openapi.oss-cn-hangzhou.aliyuncs.com/live/10034/f5540914-c5d4-41b6-8080-42a218f16a34.jpg"
                }
            ],
            "timestamp": 1576567228
        },
        {
            "result": [
                {
                    "action": "v-porn",
                    "label": "normal",
                    "rate": 0.9999052882194519,
                    "suggestion": "pass",
                    "timestamp": 1576567222,
                    "url": "http://jocloud-ai-openapi.oss-cn-hangzhou.aliyuncs.com/live/10034/50bf73a6-2555-48c2-8f33-13d2002f7e76.jpg"
                }
            ],
            "timestamp": 1576567223
        },
        {
            "result": [
                {
                    "action": "v-porn",
                    "label": "normal",
                    "rate": 0.99971604347229004,
                    "suggestion": "pass",
                    "timestamp": 1576567217,
                    "url": "http://jocloud-ai-openapi.oss-cn-hangzhou.aliyuncs.com/live/10034/4696a8a5-78f8-4c32-b696-aebbf79685bc.jpg"
                }
            ],
            "timestamp": 1576567218
        },
        {
            "result": [
                {
                    "action": "v-porn",
                    "label": "normal",
                    "rate": 0.99987661838531494,
                    "suggestion": "pass",
                    "timestamp": 1576567212,
                    "url": "http://jocloud-ai-openapi.oss-cn-hangzhou.aliyuncs.com/live/10034/6002efb8-e6d4-4527-afd8-1fd4a951d655.jpg"
                }
            ],
            "timestamp": 1576567213
        }
    ],
    "status": "running"
}

4.3 Stop the Task

# -*- coding: utf-8 -*-
#! python3.5

import requests
import uuid
import base64

host = "https://ai.jocloud.com"

appid = 1234567890  # Your Service ID
restful_id = '**********'  # Your certificate ID
restful_secret = '**********'  # Your certificate key
traceid = str(uuid.uuid4())
dataid = str(uuid.uuid4())

# headers
headers = {
    "content-type": "application/json"
}

auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + auth.decode()

traceid = str(uuid.uuid4())
task_id = 'acee5522-b198-4325-9434-61b41eb2e08a' # Fill in the taskId content returned when starting the task here

# url
url = host + '/app/%s/v1/video/live/stop?traceId=%s&taskId=%s' % (appid, traceid, task_id)

# request
res = requests.post(url, json={}, headers=headers)
print ('url=%s\ncode=%s\ndata=%s\n' % (url, res.status_code, res.text))

The call results are returned as follows:

{
    "code": 200,
    "message": "OK",
    "traceId": "9eb28f1d-a307-4e93-bcf4-66e531aa12f1",
    "taskId": "acee5522-b198-4325-9434-61b41eb2e08a",
    "timestamp": 1576567306
}

5. Update History

VersionTimeDescription
v2.2.42020-10-15Add new label in OCR recognition
V2.2.32020-10-14Add 'a-asr' action support
v2.2.22020-10-13Add 'inbed' label in Illegal recognition
v2.2.12020-09-05Add 'resultCbLevel' parameter, support to control the result callback level
v2.2.02020-08-31Add ad and ocr recognition; Update labels of 'v-terrorism' and 'v-antispam' recognition
v2.1.02020-08-24Add illegal recognition
v2.0.02020-08-17Add secondary labels in the porn recognition
v1.1.02020-06-30Remove 'interval' param in request, Set to 2s to intercept one frame
V1.0.02020-03-13Initial version

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top
<