Video Background Removal

Removing background from videos takes longer time than images relatively. Therefore, the video background removal API is designed in such a way that users are able to obtain results in asynchronous mode. Overall, three interfaces are provided for users to carry out video background removal tasks per the need.

API documentation

Interface for removing background from the submitted video:

(1)Request parameters (Header)

ParameterParameter TypeDescription
APIKEYstringYour API Key

(2) Query String

ParameterParameter TypeDescription
videoUrlurlthe URL of a video or a GIF, required
outputFormatstringoutput format of the result video, valid values are: webm, mov. The default output format is mov.

(3) Response data

 {
    "code":0, // 0 indicates success, and the other values are the corresponding error codes
    "data":{
        "taskFlag": "08ba8388bdb54498a3bb0fc92ce2341e" //The task id of the submission
    }, 
    "msg":null, // if code is not 0, the error msg of the error
    "time": 1615368038661 // the unix timestamp of server
 }

Sample Code

curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
  'https://www.cutout.pro/api/v1/video/submitTaskByUrl?videoUrl=xxxx&outputFormat=mov' 
  import requests
  response = requests.get(
    'https://www.cutout.pro/api/v1/video/submitTaskByUrl?videoUrl=xxxx&outputFormat=mov',
    headers={'APIKEY': 'INSERT_YOUR_API_KEY_HERE'},
  )
  $client = new GuzzleHttp\Client();
  $res = $client->get('https://www.cutout.pro/api/v1/video/submitTaskByUrl?videoUrl=xxxx&outputFormat=mov', [
    'headers' => [
        'APIKEY' => 'INSERT_YOUR_API_KEY_HERE'
    ]
  ]);
  CloseableHttpClient client = HttpClients.createDefault();
  URIBuilder uriBuilder = new URIBuilder("https://www.cutout.pro/api/v1/video/submitTaskByUrl");
  uriBuilder.addParameter("videoUrl", "video url");
  uriBuilder.addParameter("outputFormat", "mov");
  HttpGet httpGet = new HttpGet(uriBuilder.build());
  httpGet.setHeader("APIKEY", "INSERT_YOUR_API_KEY_HERE");

  try (CloseableHttpResponse response = client.execute(httpGet)){
    if (response.getStatusLine().getStatusCode() == HttpStatusCode.OK) {
        //todo your logic
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  var request = require('request');
  var fs = require('fs');

  request.get({
    url: 'https://www.cutout.pro/api/v1/video/submitTaskByUrl?videoUrl=xxxx&outputFormat=mov',
    headers: {
    'APIKEY': 'INSERT_YOUR_API_KEY_HERE'
    },
    encoding: null
  }, function(error, response, body) {
    // console.log(response);
  });

Interface for obtaining asynchronous webhook notifications:

  • A specified API address is required to be provided to receive asynchronous notifications, Notifications are returned in json format and posted to the specified address.
  • json exmple:
{
    "eventName":"EVENT_VIDEO_TASK_FINISHED",
    "eventData": {
        "taskFlag": "08ba8388bdb54498a3bb0fc92ce2341e",
        "resultUrl": "http://xxxxxxxxxxx", //the resulting video url with background removed
        "status": "done"
    }
}

Interface for checking task status:

(1) Request parameters (Header)

ParameterParameter TypeDescription
APIKEYstringYour API key

(2) Query String

ParameterParameter TypeDescription
taskFlagstringthe task id returned by the submission

(3) Response data

{
    "code":0, //0 indicates success, and the other values are the corresponding error codes
    "data":{
        "taskFlag": "08ba8388bdb54498a3bb0fc92ce2341e",
        "resultUrl": "http://xxxxxxxxxxx", //the resulting video url with background removed
        "status": "done", //valid values are: processing, done
        "percentage": "100", //Indicates the percentage of task completion
    },
    "msg":"error msg",if code is not 0, the error msg of the error
    "time": 1615368038661the unix timestamp of server
}

Sample Code

curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
  'https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx' 
  import requests
  response = requests.get(
    'https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx',
    headers={'APIKEY': 'INSERT_YOUR_API_KEY_HERE'},
  )
  $client = new GuzzleHttp\Client();
  $res = $client->get('https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx', [
    'headers' => [
        'APIKEY' => 'INSERT_YOUR_API_KEY_HERE'
    ]
  ]);
  CloseableHttpClient client = HttpClients.createDefault();
  
  HttpGet httpGet = new HttpGet("https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx");
  httpGet.setHeader("APIKEY", "INSERT_YOUR_API_KEY_HERE");

  try (CloseableHttpResponse response = client.execute(httpGet)){
    if (response.getStatusLine().getStatusCode() == HttpStatusCode.OK) {
        //todo your logic
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  var request = require('request');
  var fs = require('fs');

  request.get({
    url: 'https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx',
    headers: {
    'APIKEY': 'INSERT_YOUR_API_KEY_HERE'
    },
    encoding: null
  }, function(error, response, body) {
    // console.log(response);
  });

Interface for preview the frame images of the video after removing background:

(1) Request parameters (Header)

ParameterParameter TypeDescription
APIKEYstringYour API key

(2) Query String

ParameterParameter TypeDescription
videoUrlstringthe URL of a video or a GIF, required

(3) Response data

{
    "code":0, //0 indicates success, and the other values are the corresponding error codes
    "data":{
    "taskFlag": "08ba8388bdb54498a3bb0fc92ce2341e" //The task id of the submission、
    },
    "msg":"msg", //if code is not 0, the error msg of the error
    "time": 1615368038661 //the unix timestamp of server
}

Sample Code

curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
  'https://www.cutout.pro/api/v1/video/submitVideoImagePreviewTaskByUrl?videoUrl=xxxx' 
  import requests
  response = requests.get(
    'https://www.cutout.pro/api/v1/video/submitVideoImagePreviewTaskByUrl?videoUrl=xxxx',
    headers={'APIKEY': 'INSERT_YOUR_API_KEY_HERE'},
  )
  $client = new GuzzleHttp\Client();
  $res = $client->get('https://www.cutout.pro/api/v1/video/submitVideoImagePreviewTaskByUrl?videoUrl=xxxx', [
    'headers' => [
        'APIKEY' => 'INSERT_YOUR_API_KEY_HERE'
    ]
  ]);
  CloseableHttpClient client = HttpClients.createDefault();
  
  HttpGet httpGet = new HttpGet("https://www.cutout.pro/api/v1/video/submitVideoImagePreviewTaskByUrl?videoUrl=xxxx");
  httpGet.setHeader("APIKEY", "INSERT_YOUR_API_KEY_HERE");

  try (CloseableHttpResponse response = client.execute(httpGet)){
    if (response.getStatusLine().getStatusCode() == HttpStatusCode.OK) {
        //todo your logic
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  var request = require('request');
  var fs = require('fs');

  request.get({
    url: 'https://www.cutout.pro/api/v1/video/submitVideoImagePreviewTaskByUrl?videoUrl=xxxx',
    headers: {
    'APIKEY': 'INSERT_YOUR_API_KEY_HERE'
    },
    encoding: null
  }, function(error, response, body) {
    // console.log(response);
  });

Interface for checking preview task status:

(1) Request parameters (Header)

ParameterParameter TypeDescription
APIKEYstringYour API key

(2) Query String

ParameterParameter TypeDescription
taskFlagstringthe task id returned by the submission

(3) Response data

{
    "code":0,0 indicates success, and the other values are the corresponding error codes
    "data":{
        "taskFlag": "08ba8388bdb54498a3bb0fc92ce2341e",
        "previewImage": [
            {
                "time": 1.2, //the time of the video frame
                "image":"http://xxxxxxxxxxx", //the image of the original video frame
                "matting": "http://xxxxxxxxxxx" //the image after background removal
            },
            {
                "time": 2.3, //the time of the video frame
                "image":"http://xxxxxxxxxxx", //the image of the original video frame
                "matting": "http://xxxxxxxxxxx" //the image after background removal
            },
            ...
        ],
        "status": "done",valid values are: processing, done
    },
    "msg":"error msg", //if code is not 0, the error msg of the error
    "time": 1615368038661 //the unix timestamp of server
}

Sample Code

curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
  'https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx' 
  import requests
  response = requests.get(
    'https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx',
    headers={'APIKEY': 'INSERT_YOUR_API_KEY_HERE'},
  )
  $client = new GuzzleHttp\Client();
  $res = $client->get('https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx', [
    'headers' => [
        'APIKEY' => 'INSERT_YOUR_API_KEY_HERE'
    ]
  ]);
  CloseableHttpClient client = HttpClients.createDefault();
  
  HttpGet httpGet = new HttpGet("https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx");
  httpGet.setHeader("APIKEY", "INSERT_YOUR_API_KEY_HERE");

  try (CloseableHttpResponse response = client.execute(httpGet)){
    if (response.getStatusLine().getStatusCode() == HttpStatusCode.OK) {
        //todo your logic
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  var request = require('request');
  var fs = require('fs');

  request.get({
    url: 'https://www.cutout.pro/api/v1/video/getTaskInfo?taskFlag=xxxx',
    headers: {
    'APIKEY': 'INSERT_YOUR_API_KEY_HERE'
    },
    encoding: null
  }, function(error, response, body) {
    // console.log(response);
  });