Creating a Job

Function

Create a video content moderation job.

URI

  • URI format:
POST /v2/{project_id}/services/video-moderation/tasks
  • Parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID corresponding to the region where the service is located. For details about how to obtain the project ID, see Obtaining the Project ID.

Request Parameters

  • Example request
    POST /v2/6204a5bd270343b5885144cf9c8c158d/services/video-moderation/tasks  
     {    
         "name": "task-test",    
         "description": "description",    
         "input": {    
                "type": "obs",    
                "data": [    
                       {    
                         "bucket": "obs-iva",
                         "index": 0,    
                         "path": "input/demo.mp4"    
                       } 
                ]    
         },    
         "output": {    
                "obs": {    
                       "bucket": "obs-iva",    
                       "path": "output/"    
                },
           "hosting": {}    
         },    
         "service_config": {    
                "common": {    
                       "frame_interval": 5,    
                       "categories": "porn,terrorism,politics",
                       "text_categories": "porn,politics",
                       "upload": "false",
                       "use_ocr": "true",
                       "use_sis": "true"  
                }    
         },    
        "service_version":"1.2"    
     }
  • Parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Job name, which consists of 1 to 100 characters, including letters (A to Z and a to z), digits (0 to 9), hyphens (-), and underscores (_).

description

No

String

Job description, which consists of a maximum of 500 characters.

input

Yes

Object

Video data input list. Currently, only the following input types are supported. Only one input channel is supported at a time.

  • obs: Read video data from OBS on HUAWEI CLOUD.
  • url: Read video data from a specified URL.

For details, see task.input.

output

Yes

Object

List of output result data. Currently, only the following output types are supported:

  • obs: Export the results to the OBS bucket you specified.
  • hosting: Host the results on OBS at the service side. The OBS path is specified by the service. You can obtain the path by using the API that queries a single task. For details, see Querying a Single Job.

For details, see task.output.

service_config

No

Object

Service algorithm configuration. The field structure is related to the service. Currently, the configuration item is common. For details about the parameter definition, see serviceConfig.common field structure.

service_version

Yes

String

Version, which is set to 1.2.

  • service_config.common field structure

Parameter

Mandatory

Type

Description

frame_interval

Yes

Integer

Frame capture interval, in seconds per frame

categories

Yes

String

Video moderation scenarios.

  • politics: Detect political figures in the video.
  • terrorism: Detect terrorism-related element in the video.
  • porn: Detect pornography content in the video.

You can set the parameter to the preceding values to check the corresponding elements.

NOTE:

To configure multiple moderation scenarios, use a comma (,) to separate every two scenario names, for example, categories: politics,terrorism,porn.

text_categories

No

String

For audio or text content moderation, the following scenarios are supported:

  • politics: Detect the names of political figures appeared in audios or texts.
  • porn: Detect pornography content appeared in audios or texts.
  • ad: Detect advertisements appeared in audios or texts.
  • abuse: Detect abusive content appeared in audios or texts.
  • contraband: Detect contraband content appeared in audios or texts.
  • flood: Detect spam content appeared in audios or texts.

Set this parameter to your desired scenario before using an audio or text moderation service.

NOTE:

To configure multiple moderation scenarios, use a comma (,) to separate every two scenario names, for example, text_categories: politics,porn.

use_sis

No

String

Indicates whether to enable the audio content moderation.

  • true: enable
  • false: disable

If this parameter is not set or is left blank, the default value is false.

use_ocr

No

String

Indicates whether to enable the text content moderation.

  • true: enable
  • false: disable

If this parameter is not set or is left blank, the default value is false.

upload

No

String

Indicates whether to upload the detected problematic images to the cloud.

  • true: enable
  • false: disable

If this parameter is not set or is left blank, the default value is false.

If you set true to this parameter, please set an OBS output directory beforehand. Otherwise, image upload would fail. Once rightfully configured, a folder named after the task_id would be automatically created under the configured output path and the detected problematic images uploaded to that directory.

Response Parameters

  • Example response
    [  
      {      "id": "f18320e61e4c4dc685aa2dfc22a28dc5"   }  
    ]
  • Job ID description

    Parameter

    Type

    Description

    id

    String

    Job ID

Status Codes

  • Normal

    201

  • Abnormal

    Status Code

    Description

    400 Bad Request

    Request error. For details about the returned error code, see Error Codes.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    No operation permission.

    404 Not Found

    The requested resource was not found.

    500 Internal Server Error

    Internal service error.

    503 Service Unavailable

    Service unavailable.