Single Video Swap Endpoint
Overview
Single Video Swap endpoint allows swapping faces in all detected faces within a single video.
Request
--request POST 'https://modelslab.com/api/v6/deepfake/single_video_swap' \
Make a POST
request to https://modelslab.com/api/v6/deepfake/single_video_swap endpoint and pass the required parameters in the request body.
Body Attributes
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization. | ExampleKey123 |
init_image | The image containing multiple faces to be swapped. | [Image URL] |
init_video | The video containing the face(s) to replace the faces in the image. Only videos less than 1 minute are accepted. If using YouTube, ensure the video is not made for kids or classified as adult content. | [Video URL] |
output_format | The output formart of a video as a string e.g mp4. | string eg mp4 |
watermark | Indicate if you want the generated result to have a watermark. Default is true. | true/false |
webhook | Set a URL to receive a POST API call once the image generation is complete. | [Webhook URL] |
track_id | This ID is returned in the response to the webhook API call. This will be used to identify the webhook request. | Integer |
Example
Body
Body
{
"key": "",
"init_image":"https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=",
"init_video":"https://www.youtube.com/watch?v=xHC_qFPeXt0",
"output_format":"mp4",
"webhook":null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"init_image":"https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=",
"init_video":"https://www.youtube.com/watch?v=xHC_qFPeXt0",
"output_format":"mp4",
"webhook":null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v6/deepfake/single_video_swap", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"init_image" =>"https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=",
"init_video" => "https://www.youtube.com/watch?v=xHC_qFPeXt0",
"output_format" => "mp4",
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/deepfake/single_video_swap',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v6/deepfake/single_video_swap',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"init_image":"https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=",
"init_video":"https://www.youtube.com/watch?v=xHC_qFPeXt0",
"output_format":"mp4",
"webhook":null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v6/deepfake/single_video_swap"
payload = json.dumps({
"key": "",
"init_image":"https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=",
"init_video":"https://www.youtube.com/watch?v=xHC_qFPeXt0",
"output_format":"mp4",
"webhook":NOne,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"key\": \" \",\r\n \"init_image\":\"https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=\",\r\n \"init_video\":\"https://www.youtube.com/watch?v=xHC_qFPeXt0\",\r\n \"output_format\":mp4,\r\n \"webhook\":null,\r\n \"track_id\": null\r\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/deepfake/single_video_swap")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 10.1,
"id": 278,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/4babc755-8276-4d23-addf-17e420a514cb.mp4"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/generations/4babc755-8276-4d23-addf-17e420a514cb.mp4"
],
"meta": {
"file_prefix": "4babc755-8276-4d23-addf-17e420a514cb",
"outdir": "out/",
"seed": 1282720418,
"source_image": "https://media.gettyimages.com/id/1669190297/photo/new-delhi-india-prime-minister-narendra-modi-of-india-waits-to-greet-delegates-to-the-g20.jpg?s=612x612&w=0&k=20&c=u6bSNENkX0CqFajpRorPvpnTnmkG7kVTJTHQRiJaCdE=",
"target_video_url": "https://www.youtube.com/watch?v=xHC_qFPeXt0",
"watermark": "yes",
"watermark_image": null
}
}