POST
/v1/video-swap
Process video files for face swapping with frame-by-frame consistency. Supports up to 4K resolution and maintains temporal coherence across frames.
โก Asynchronous Processing
Video processing is asynchronous. The API returns a job_id immediately. Use GET /v1/status/{job_id} to check progress.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
source_image | string | Yes | Base64 or URL of the face image to use |
target_video | string | Yes | Base64 or URL of the video to process |
quality | string | No | "standard", "high", "4k" (default: "high") |
output_format | string | No | "mp4", "webm", "mov" (default: "mp4") |
face_enhance | boolean | No | Apply face enhancement for better quality (default: true) |
webhook_url | string | No | URL to receive completion webhook |
Video Limits
500MB
Max File Size
10 min
Max Duration
4K
Max Resolution
Code Examples
PyPython
import deepswapai
client = deepswapai.Client(api_key="YOUR_API_KEY")
# Start video swap job
job = client.video_swap(
source_image="path/to/face.jpg",
target_video="path/to/video.mp4",
quality="4k",
face_enhance=True
)
print(f"Job ID: {job.id}")
print(f"Estimated time: {job.estimated_time}s")
# Wait for completion (with progress callback)
def on_progress(progress):
print(f"Progress: {progress}%")
result = job.wait_for_completion(on_progress=on_progress)
# Download result
result.download("output.mp4")
print(f"Saved to output.mp4")JSJavaScript
import DeepSwapAI from '@deepswapai/sdk';
const client = new DeepSwapAI({ apiKey: 'YOUR_API_KEY' });
// Start video swap job
const job = await client.videoSwap({
sourceImage: 'https://example.com/face.jpg',
targetVideo: 'https://example.com/video.mp4',
quality: '4k',
webhookUrl: 'https://yoursite.com/webhook'
});
console.log('Job ID:', job.id);
// Poll for status
const result = await job.waitForCompletion({
onProgress: (progress) => console.log(`Progress: ${progress}%`)
});
console.log('Output URL:', result.outputUrl);$cURL
curl -X POST https://api.deepswapai.com/v1/video-swap \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source_image": "https://example.com/face.jpg",
"target_video": "https://example.com/video.mp4",
"quality": "4k",
"webhook_url": "https://yoursite.com/webhook"
}'Response
{
"success": true,
"job_id": "vjob_xyz789abc",
"status": "processing",
"estimated_time": 120,
"progress": 0,
"credits_estimated": 50
}Webhook Payload
When processing completes, we'll POST to your webhook URL:
{
"event": "video_swap.completed",
"job_id": "vjob_xyz789abc",
"status": "completed",
"output_url": "https://cdn.deepswapai.com/results/xyz789.mp4",
"duration": 45.2,
"resolution": "3840x2160",
"processing_time": 118500,
"credits_used": 48
}