The Video Redaction API is used to automatically hide unwanted content in images. Using our automated APIs, you can define the types of content that need to be hidden such as explicit/illegal content or personal content.
This API is similar to the Video Moderation API, except that in addition to detecting unwanted content, the Video Redaction API will go one step further and create an updated version of the video where any unwanted content will have been hidden.
Below is an example of the redaction API configured to hide faces of children under 18:
The Sightengine API uses a key pair that consists of an API user id and an API secret for authentication. To get your own API credentials, create an account and go the the API key page to retrieve them.
The following concepts can be detected and hidden with the Video Redaction API. You can select any combination of the following concepts to customize the results you get.
nudity | Hide all types of nudity from explicit to suggestive |
nudity-raw | Hide raw nudity only: sexual activity, sexual display and erotica |
- | |
face | Hide all faces |
face-minor | Hide faces of children under 18 |
- | |
license-plate | Hide license plates |
- | |
offensive | Hide offensive signs and gestures |
- | |
weapon | Hide weapons such as guns and rifles |
alcohol | Hide alcoholic bevereages |
recreational-drug | Hide recreational drugs such as joints, cannabis |
medical-drug | Hide medical drugs |
- | |
gore | Hide gore and horrific imagery |
- | |
text-natural | Hide naturally occurring text |
text-embedded | Hide embedded text |
- | |
profanity | Hide written profanity: insults, racial slurs, inappropriate language |
link | Hide embedded URLs and links |
Hide embedded email addresses | |
phone | Hide embedded phone numbers |
social | Hide social network accounts and mentions |
- | |
qr | Hide QR codes |
- |
Other custom concepts are available upon request. Feel free to reach out if you have specific needs.
By default, the engine will pixelate any unwanted areas of the video. Other methods are available:
Method | Description | Availability |
Pixelation | Unwanted areas are hidden by pixelating the video with large square blocks, such as large pixels. This is usually the recommended approach. | Enabled by default |
Masking | Unwanted areas are hidden with a uniform box. The box is typically black but other colors are possible. This is the most robust approach for anonymization. | Available upon request |
Blurring | Unwanted areas are hidden through blurring. | Available upon request |
Let's say you want to hide nudity, child faces, email addresses and phone numbers that may be embedded in videos. You will be using the following concepts: nudity, face-minor email and phone.
curl -X POST 'https://api.sightengine.com/1.0/video/transform.json' \
-F 'media=@/path/to/video.mp4' \
-F 'concepts=nudity,face-minor,email,phone' \
-F 'api_user={api_user}' \
-F 'api_secret={api_secret}'
# this example uses requests
import requests
import json
params = {
'concepts': 'nudity,face-minor,email,phone',
'api_user': '{api_user}',
'api_secret': '{api_secret}'
}
files = {'media': open('/path/to/video.mp4', 'rb')}
r = requests.post('https://api.sightengine.com/1.0/video/transform.json', files=files, data=params)
output = json.loads(r.text)
$params = array(
'media' => new CurlFile('/path/to/video.mp4'),
'concepts' => 'nudity,face-minor,email,phone',
'api_user' => '{api_user}',
'api_secret' => '{api_secret}',
);
// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/video/transform.json');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
curl_close($ch);
$output = json_decode($response, true);
// this example uses axios and form-data
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
data = new FormData();
data.append('media', fs.createReadStream('/path/to/video.mp4'));
data.append('concepts', 'nudity,face-minor,email,phone');
data.append('api_user', '{api_user}');
data.append('api_secret', '{api_secret}');
axios({
method: 'post',
url:'https://api.sightengine.com/1.0/video/transform.json',
data: data,
headers: data.getHeaders()
})
.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 above call works for videos that are no larger than 50MB. If you need to transform a larger video, you should first upload it separately to the Upload API, and then submit the media id to the Redaction API.
The API will then return a JSON response. The response indicates that the process has begun.
{
"status": "success",
"request": {
"id": "req_56JCYHWOIpuU8dpmxeAKw",
"timestamp": 1513479454.1576,
},
"media": {
"id": "med_56JCMAeruaoeSk4PdAqjf",
"uri": "video.mp4"
}
}
Now that the process has begun, you can use the media id to ask for update on the redaction process.
You can ask for updates on the transformation process by pinging the API.
# {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);
});
If the redaction process is still ongoing, the output.data.status field will be set at ongoing.
If the redaction process has finished, the output.data.status field will be finished and the a signed download URL will be returned in the API response under the output.data.transform.location field:
{
"status": "success",
"request": {
"id": "req_ajfOdDZAsl5hQ2zZBdndi",
"timestamp": 1513479479.1786,
"operations": 0
},
"output": {
"media": {
"id": "med_56JCMAeruaoeSk4PdAqjf",
"uri": "video.mp4"
},
"request": "req_56JCYHWOIpuU8dpmxeAKw",
"data": {
"status": "finished",
"started": 1513479454.1576,
"last_update": 1513479472.3956,
"operations": 35,
"transform": {
"location": "https://storage-eu1.sightengine.com/u/beaf38/aj/f3/...."
}
}
}
}
The provided URL can then be used to download the transformed video. The URL is signed and can be used to download the video for a limited period of time (up to 2 hours).
Was this page helpful?