Video Faceswap
Video Faceswap is a powerful tool for creators, filmmakers, and meme enthusiasts. With this innovative technology, you can effortlessly replace faces in videos
1import requests
2import json
3
4url = "https://api.segmind.com/v1/videofaceswap"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "https://segmind-sd-models.s3.amazonaws.com/display_images/videoFaceSwap/faceswap-image.jpg",
12 "video_input": "https://segmind-sd-models.s3.amazonaws.com/display_images/videoFaceSwap/faceswap-input.mp4",
13 "face_restore": true,
14 "input_faces_index": "0",
15 "source_faces_index": "0",
16 "face_restore_visibility": 1,
17 "codeformer_weight": 0.95,
18 "detect_gender_input": "no",
19 "detect_gender_source": "no",
20 "frame_load_cap": 0,
21 "base_64": false
22}
23
24response = requests.post(url, headers=headers, json=data)
25
26if response.status_code == 200:
27 result = response.json()
28 print(json.dumps(result, indent=2))
29else:
30 print(f"Error: {response.status_code}")
31 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/videofaceswap"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "https://segmind-sd-models.s3.amazonaws.com/display_images/videoFaceSwap/faceswap-image.jpg",
12 "video_input": "https://segmind-sd-models.s3.amazonaws.com/display_images/videoFaceSwap/faceswap-input.mp4",
13 "face_restore": true,
14 "input_faces_index": "0",
15 "source_faces_index": "0",
16 "face_restore_visibility": 1,
17 "codeformer_weight": 0.95,
18 "detect_gender_input": "no",
19 "detect_gender_source": "no",
20 "frame_load_cap": 0,
21 "base_64": false
22}
23
24response = requests.post(url, headers=headers, json=data)
25
26if response.status_code == 200:
27 result = response.json()
28 print(json.dumps(result, indent=2))
29else:
30 print(f"Error: {response.status_code}")
31 print(response.text)API Endpoint
https://api.segmind.com/v1/videofaceswapParameters
frame_load_caprequiredintegerTotal frames to process, Set '0' to process Full video
0Range: 0 - 500input_faces_indexrequiredstringIndex of the input faces: the leftmost face index is 0. Multiple faces can be selected using a comma (,)
"0"source_faces_indexrequiredstringIndex of the source faces: the leftmost face index is 0. Multiple faces can be selected using a comma (,)
"0"source_imgrequiredstring (uri)Your face goes here. A closeup shot would be ideal.
"https://segmind-sd-models.s3.amazonaws.com/display_images/videoFaceSwap/faceswap-image.jpg"video_inputrequiredstring (uri)The face you want to swap with. Can be a gif too.
"https://segmind-sd-models.s3.amazonaws.com/display_images/videoFaceSwap/faceswap-input.mp4"base_64optionalbooleanBase64 encoding of the output
falsecodeformer_weightoptionalnumberWeight of codeformer
0.95Range: 0 - 1detect_gender_inputoptionalstringDetect gender from input
"no""no""male""female"detect_gender_sourceoptionalstringDetect gender from source
"no""no""male""female"face_restoreoptionalbooleanEnable face restoration
trueface_restore_visibilityoptionalnumberVisibility of face restoration
1Range: 0.1 - 1Response Type
Returns: Video
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out