Skip to main content

Specific Video Swap Endpoint

Overview

Specific Video Swap endpoint allows swapping specific faces according to reference face.

Request

--request POST 'https://modelslab.com/api/v6/deepfake/specific_video_swap' \

Make a POST request to https://modelslab.com/api/v6/deepfake/specific_video_swap endpoint and pass the required parameters in the request body.

Body Attributes

ParameterDescriptionValues
keyYour unique API key used for authorization.""
init_imageThe image containing multiple faces to be swapped.url
init_videoThe video containing the face(s) to replace the faces in the image.url
reference_imageThe image url to be used for face swapping.url
output_formatThe format output that you would want the video to be like e.g.mp4
watermarkIndicate if you want the generated result to have a watermark. Default is true.true/false
webhookSet a URL to receive a POST API call once the image generation is complete.url
track_idThis ID is returned in the response to the webhook API call and will be used to identify the request.int

Example

Body

Body
{
"key": "",
"init_video": "https://www.youtube.com/watch?v=H0se-qAJARM",
"init_image" :"https://media.gq-magazin.de/photos/60a4de637986d15b5045a018/16:9/w_1920,c_limit/robert-downey-jr-star-wars.jpg",
"reference_image": "https://media.gq-magazin.de/photos/60a4de637986d15b5045a018/16:9/w_1920,c_limit/robert-downey-jr-star-wars.jpg",
"output_format": "mp4",
"webhook": null,
"track_id": null
}

Request

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key": "",
"init_video": "https://www.youtube.com/watch?v=H0se-qAJARM",
"init_image" :"https://media.gq-magazin.de/photos/60a4de637986d15b5045a018/16:9/w_1920,c_limit/robert-downey-jr-star-wars.jpg",
"reference_image": "https://media.gq-magazin.de/photos/60a4de637986d15b5045a018/16:9/w_1920,c_limit/robert-downey-jr-star-wars.jpg",
"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/specific_video_swap", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

Example Response

{
"status": "success",
"generationTime": 10.1,
"id": 298,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/9e252508-daf1-4673-a503-afe04dacfc1e.mp4"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/generations/9e252508-daf1-4673-a503-afe04dacfc1e.mp4"
],
"meta": {
"face_detector_score": 0.45,
"file_prefix": "9e252508-daf1-4673-a503-afe04dacfc1e",
"outdir": "out/",
"reference_face_distance": 0.75,
"reference_frame_number": 5,
"seed": 521160230,
"source_image": "https://media.gq-magazin.de/photos/60a4de637986d15b5045a018/16:9/w_1920,c_limit/robert-downey-jr-star-wars.jpg",
"target_video_url": "https://www.youtube.com/watch?v=H0se-qAJARM",
"watermark": "yes",
"watermark_image": null
}
}