Products

SIGN UP LOG IN

Video Moderation / Interact with Video Moderation

Interact with Video Moderation Jobs

Introduction

Once you have launched video moderation jobs, such as live stream moderation jobs, you will receive callbacks from the Moderation Engine.

Callbacks are useful to keep you informed of the progress of your moderation jobs, and to keep you informed of any unwanted content.

On top of this, you can directly interact with moderation jobs, for instance to list on-going jobs or to stop a moderation job before it reaches it's normal end.

Get the list of on-going video jobs

At any time you can request a list of on-going video jobs, for instance video moderations that have been launched but have not reached the stopped or finished status.

This can be useful if you hit your maximum concurrency limit, to see what moderations are on-going, or if you wish to monitor the progress of videos but don't have access to the specific request or media ids.


curl -X GET -G 'https://api.sightengine.com/1.0/video/ongoing.json' \
  -d 'api_user={api_user}' \
  -d 'api_secret={api_secret}'


# this example uses requests
import requests
import json

params = {'api_user': '{api_user}', 'api_secret': '{api_secret}'}
r = requests.get('https://api.sightengine.com/1.0/video/ongoing.json', params=params)

output = json.loads(r.text)


$params = array(
  'api_user' => '{api_user}',
  'api_secret' => '{api_secret}',
);

// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/video/ongoing.json?'.http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$output = json_decode($response, true);


// this example uses axios
const axios = require('axios');

axios.get('https://api.sightengine.com/1.0/video/ongoing.json', {
  params: {
    'api_user': '{api_user}',
    'api_secret': '{api_secret}',
  }
})
.then(function (response) {
  // on success: handle response
  console.log(response.data);
})
.catch(function (error) {
  // handle error
  if (error.response) console.log(error.response.data);
  else console.log(error.message);
});

The JSON response contains an array named ongoing that lists all ongoing video jobs along with the corresponding request id, media id and the timestamp of the job's last update. If no jobs are ongoing, the array will be empty: [].

              
              
{
    "status": "success",
    "request": {
        "id": "req_bclYFDZXBa1omsi0gbr4m",
        "timestamp": 1643374705.771987,
        "operations": 0
    },
    "ongoing": [
        {
            "requestid": "req_bclYjxHNnIcZEeFrIqUrs",
            "mediaid": "med_bclYuqrBCbcydqtaPQDj7",
            "type": "video_moderation",
            "last_update": 1643374705
        }
    ]
}
              
          

Get the status and results of an on-going video job

Please use callbacks to track on-going jobs. Callbacks are much more efficient for both you and Sightengine. Polling requests are rate-limited so polling would not scale and might introduce unwanted delays. Learn how


# {media_id} is the id of the media that is being processed
curl -X GET -G 'https://api.sightengine.com/1.0/video/byid.json' \
  -d 'id={media_id}' \
  -d 'api_user={api_user}' \
  -d 'api_secret={api_secret}'


# this example uses requests
import requests
import json

params = {
  # {media_id} is the id of the media that is being processed
  'id': '{media_id}',
  'api_user': '{api_user}',
  'api_secret': '{api_secret}'
}
r = requests.get('https://api.sightengine.com/1.0/video/byid.json', params=params)

output = json.loads(r.text)


$params = array(
  // {media_id} is the id of the media that is being processed
  'id' => '{media_id}',
  'api_user' => '{api_user}',
  'api_secret' => '{api_secret}',
);

// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/video/byid.json?'.http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$output = json_decode($response, true);


// this example uses axios
const axios = require('axios');

axios.get('https://api.sightengine.com/1.0/video/byid.json', {
  params: {
    'id': '{media_id}',
    'api_user': '{api_user}',
    'api_secret': '{api_secret}',
  }
})
.then(function (response) {
  // on success: handle response
  console.log(response);
})
.catch(function (error) {
  // handle error
  if (error.response) console.log(error.response.data);
  else console.log(error.message);
});

The JSON response contains an object named output with the current output of the video job.

              
              
{
  "status": "success",
  "request": {
    "id": "req_bcm7U8KM0lJkz6JYY2w4P",
    "timestamp": 1643375237.444607,
    "operations": 0
  },
  "output": {
    "media": {
        "id": "med_bclYuqrBCbcydqtaPQDj7",
        "uri": "videoname.mp4"
    },
    "request": "req_bclYjxHNnIcZEeFrIqUrs",
    "data": {
      "status": "ongoing",
      "started": 1643375232.230313,
      "last_update": 1643375237.343219,
      "progress": 0.24,
      "operations": 6,
      "frames": [
        .....
      ]
    }
  }
}
   

Stop a video moderation before it ends

In general you should not worry about having to stop Video Moderation. Moderation actions automatically finish once the video ends or once the video timeout has been reached. Early Stopping is useful either if you have a long running video and realize you don't want/need to run it through moderation until the end, or if you made a mistake and need to stop Moderation immediately.

To stop a video, simply perform the following command, providing the video's media id.


# {media_id} is the id of the media that is being moderated
# this id is given to you by the API when you perform a moderation request
curl -X DELETE 'https://api.sightengine.com/1.0/video/byid.json' \
  -d 'id={media_id}' \
  -d 'api_user={api_user}' \
  -d 'api_secret={api_secret}'


# this example uses requests
import requests
import json

data = {
  # {media_id} is the id of the media that is being moderated
  # this id is given to you by the API when you perform a moderation request
  'id': '{media_id}',
  'api_user': '{api_user}',
  'api_secret': '{api_secret}'
}
r = requests.delete('https://api.sightengine.com/1.0/video/byid.json', data=data)

output = json.loads(r.text)


$params = array(
  // {media_id} is the id of the media that is being moderated
  // this id is given to you by the API when you perform a moderation request
  'id' => '{media_id}',
  'api_user' => '{api_user}',
  'api_secret' => '{api_secret}',
);

// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/video/byid.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$response = curl_exec($ch);
curl_close($ch);

$output = json_decode($response, true);


// this example uses axios and querystring
const axios = require('axios');
const qs = require('querystring');

data = {
  'id': '{media_id}',
  'api_user': '{api_user}',
  'api_secret': '{api_secret}',
}

axios.delete('https://api.sightengine.com/1.0/video/byid.json', {params: data})
.then(function (response) {
  // on success: handle response
  console.log(response.data);
})
.catch(function (error) {
  // handle error
  if (error.response) console.log(error.response.data);
  else console.log(error.message);
});

If the call is successful, the response will contain the success status.

                  
                  
{
  "status": "success",
  "request": {
    "id": "req_bcm7U8KM0lJkz6JYY2w4P",
    "timestamp": 1643375237.444607,
    "operations": 0
  }
}
      
 

Was this page helpful?