Scan Video Faces
curl --request POST \
--url https://api.goenhance.ai/api/v1/videofaceswap/scan \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"reference_video": "https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4"
}
'import requests
url = "https://api.goenhance.ai/api/v1/videofaceswap/scan"
payload = { "reference_video": "https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({reference_video: 'https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4'})
};
fetch('https://api.goenhance.ai/api/v1/videofaceswap/scan', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goenhance.ai/api/v1/videofaceswap/scan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reference_video' => 'https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goenhance.ai/api/v1/videofaceswap/scan"
payload := strings.NewReader("{\n \"reference_video\": \"https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goenhance.ai/api/v1/videofaceswap/scan")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"reference_video\": \"https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goenhance.ai/api/v1/videofaceswap/scan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reference_video\": \"https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "Success",
"data": {
"img_uuid": "8d3f2a61-5b7c-4e0a-9f12-3c4d5e6f7a8b",
"cost": 1
}
}{
"code": 401,
"msg": "Token Error"
}{
"code": 500,
"msg": ""
}Face Swap API
Video Face Scan API
Find every person in a video before a multi-person face swap. Returns a face thumbnail and screen time for each person, ready to pick who gets swapped.
POST
/
api
/
v1
/
videofaceswap
/
scan
Scan Video Faces
curl --request POST \
--url https://api.goenhance.ai/api/v1/videofaceswap/scan \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"reference_video": "https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4"
}
'import requests
url = "https://api.goenhance.ai/api/v1/videofaceswap/scan"
payload = { "reference_video": "https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({reference_video: 'https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4'})
};
fetch('https://api.goenhance.ai/api/v1/videofaceswap/scan', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goenhance.ai/api/v1/videofaceswap/scan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reference_video' => 'https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goenhance.ai/api/v1/videofaceswap/scan"
payload := strings.NewReader("{\n \"reference_video\": \"https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goenhance.ai/api/v1/videofaceswap/scan")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"reference_video\": \"https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goenhance.ai/api/v1/videofaceswap/scan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reference_video\": \"https://cdn.goenhance.ai/images/static/demo/face-swap-1.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "Success",
"data": {
"img_uuid": "8d3f2a61-5b7c-4e0a-9f12-3c4d5e6f7a8b",
"cost": 1
}
}{
"code": 401,
"msg": "Token Error"
}{
"code": 500,
"msg": ""
}The scan is the first step of a multi-person face swap. It finds the distinct people in a video and returns one thumbnail per person. You then choose which people to swap and pass the scan ID to Video Face Swap.
Pricing
1 token per scan (= $0.02 USD). The length of the video does not change the price. The scan and the swap are billed separately. The swap costs the same as a single-person swap, see Video Face Swap pricing.Request
curl --request POST \
--url https://api.goenhance.ai/api/v1/videofaceswap/scan \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"reference_video": "https://example.com/party.mp4"
}'
reference_videofollows the same rules as in Video Face Swap: the same formats, a 100 MB limit and 2 to 120 seconds for videos, and the usual GIF limits for GIFs.- The whole video is scanned. To swap only part of it, set
start_timeandend_timein the swap request.
{
"code": 0,
"msg": "Success",
"data": {
"img_uuid": "8d3f2a61-5b7c-4e0a-9f12-3c4d5e6f7a8b",
"cost": 1
}
}
Result
Poll Task Detail with theimg_uuid. When the scan succeeds, data.json has one entry per person:
"json": [
{
"type": "image",
"value": "https://.../person_0.jpg",
"person": 0,
"appearances": 86,
"first_seen": 0.0,
"last_seen": 56.0
},
{
"type": "image",
"value": "https://.../person_1.jpg",
"person": 1,
"appearances": 75,
"first_seen": 0.0,
"last_seen": 56.0
}
]
| Field | Meaning |
|---|---|
value | Thumbnail of the person’s face. Show it to your users so they can pick who to swap. |
person | The person’s index, starting at 0. Use it in faces[].person in the swap request. |
appearances | How many sampled frames the person appears in. The video is sampled at 2 frames per second, so 86 is roughly 43 seconds on screen. |
first_seen, last_seen | First and last time the person appears, in seconds. |
- People are sorted by
appearances, most frequent first, soperson: 0is the person on screen the longest. - At most 10 people are returned. If the video has more, you get the 10 who appear most.
- If no face is found anywhere in the video, the task fails with the message
No face detected in the video. - The scan ID can be used for swaps for 7 days. After that, scan the video again.
Next step
Send the scan ID asscan_id and the people you want to swap as faces to Video Face Swap.Body
application/json
