Skip to main content

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

ParameterDescriptionValues
keyYour API Key used for request authorization.ExampleKey123
init_imageThe image containing multiple faces to be swapped.[Image URL]
init_videoThe 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_formatThe output formart of a video as a string e.g mp4.string eg 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.[Webhook URL]
track_idThis 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://plus.unsplash.com/premium_photo-1661508557554-e3d96f2fdde5?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OXx8YmVhdXRpZnVsJTIwZ2lybHxlbnwwfHwwfHx8MA%3D%3D",
"init_video":"https://tawk.link/6332cd5154f06e12d8971855/vc/66d997a6a2bc5fe2b627a250/v/4239c555189b772d5ca1bd5aa4bf872c4c12a07e/sdfsdfsdf.mp4",
"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_image":"https://plus.unsplash.com/premium_photo-1661508557554-e3d96f2fdde5?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OXx8YmVhdXRpZnVsJTIwZ2lybHxlbnwwfHwwfHx8MA%3D%3D",
"init_video":"https://tawk.link/6332cd5154f06e12d8971855/vc/66d997a6a2bc5fe2b627a250/v/4239c555189b772d5ca1bd5aa4bf872c4c12a07e/sdfsdfsdf.mp4",
"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));

Response

Example Response

{
"status": "success",
"generationTime": 10.1,
"id": 278,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e9b7ee18-2c7d-4268-ac40-fe1d1d4e503a.mp4"
],
"proxy_links": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e9b7ee18-2c7d-4268-ac40-fe1d1d4e503a.mp4"
],
"meta": {
"seed": 286642771,
"source_image": "https://plus.unsplash.com/premium_photo-1661508557554-e3d96f2fdde5?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OXx8YmVhdXRpZnVsJTIwZ2lybHxlbnwwfHwwfHx8MA%3D%3D",
"target_video_url": "https://tawk.link/6332cd5154f06e12d8971855/vc/66d997a6a2bc5fe2b627a250/v/4239c555189b772d5ca1bd5aa4bf872c4c12a07e/sdfsdfsdf.mp4",
"output_format": "mp4",
"outdir": "out/",
"file_prefix": "e9b7ee18-2c7d-4268-ac40-fe1d1d4e503a",
"watermark": "yes",
"watermark_image": null
},
"future_links": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e9b7ee18-2c7d-4268-ac40-fe1d1d4e503a.mp4"
]
}