FaceSwap

Experience seamless digital transformations with our Image and Video Face Swap API.

Image and Video Face Swap API

Unleash the power of digital transformation with our revolutionary Image and Video Face Swap API. This cutting-edge tool is designed to elevate your digital content creation to new heights, offering seamless face swapping capabilities for both images and videos.

Key Features

  • High-quality face swapping technology: Our API utilizes state-of-the-art algorithms to ensure seamless and realistic face swaps in both images and videos.

  • Easy integration: Comprehensive documentation and straightforward implementation make integrating our API into your project quick and hassle-free.

  • Customization options: Tailor the face swapping experience to suit your needs with customizable parameters for face detection, alignment, and blending.

  • Scalability and reliability: Built to handle high volumes of requests with minimal latency, ensuring a smooth and reliable user experience.

Benefits

  • Create hilarious memes, captivating social media content, and personalized experiences for your users.

  • Add fun filters to your mobile app, create entertaining videos for your social media platforms, or enhance your marketing campaigns with interactive experiences.

Details

1. Face Swap Image

This endpoint is used to perform face swapping on images.

  • Endpoint: https://www.capix.uz/v2/faceswap/image/

  • Method: POST

  • Request Headers:

    • Content-Type: application/json

    • token: API_TOKEN

  • Request Body:

    {
      "target_url": "https://storage.ws.pho.to/s2/7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg",
      "swap_url": "https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg"
    }

2. Face Swap Video

This endpoint is used to perform face swapping on videos.

  • Endpoint: https://www.capix.uz/v2/faceswap/video/

  • Method: POST

  • Request Headers:

    • Content-Type: application/json

    • token: API_TOKEN

  • Request Body:

    {
      "target_url": "https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4",
      "swap_url": "https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg"
    }
    • target_url: URL of the video where the face swap will be applied.

    • swap_url: URL of the image containing the face to be swapped onto the target video.

3. Get Face Swap Result

This endpoint is used to retrieve the result of a face swap operation initiated earlier. It requires the request_id obtained from the response of either the image or video face swap request.

  • Endpoint: https://www.capix.uz/v2/faceswap/result/

  • Method: POST

  • Request Headers:

    • Content-Type: application/json

    • token: API_TOKEN

  • Request Body:

    {
      "request_id": "REQUEST_ID"
    }
    • request_id: ID of the face swap request for which the result is being retrieved.

Code snippetes

Image Process

curl -X POST \
  -H "Content-Type: application/json" \
  -H "token: API_TOKEN" \
  -d '{
    "target_url": "https://storage.ws.pho.to/s2/7aa4876bc1f50bc92fc54cb3c326181ac5bbf5ef_m.jpeg",
    "swap_url": "https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg"
}' \
  https://www.capix.uz/v2/faceswap/image/

Video Process

curl -X POST \
  -H "Content-Type: application/json" \
  -H "token: API_TOKEN" \
  -d '{
    "target_url": "https://storage.ws.pho.to/s2/7e2131eaef5e5cbb0d2c9eef7e2f19343b5a1292.mp4",
    "swap_url": "https://storage.ws.pho.to/s2/818f3e408ee37c090cf23a3d12e15a08ada80ad9_m.jpeg"
}' \
  https://www.capix.uz/v2/faceswap/video/

Result

curl -X POST \
  -H "Content-Type: application/json" \
  -H "token: API_TOKEN" \
  -d '{
      "request_id": "REQUEST_ID"
}' \
  https://www.capix.uz/v2/faceswap/result/

Video Duration

This API processes only 4 seconds of the video. For example, if you upload a 35-second video, the result will be the first 4 seconds. So, there would be a question: How can we do the whole video? The answer is split. For that, you have to split your video into several 4-seconds and upload each. Although it causes a lot of request usage, you can do it at a high speed. For that, you have to use the API simultaneously, or, in other words, threading or asyncronous. After you do all the background tasks, you will get each result and cover the whole result. You can split the video in any language. For example, in Python, you can split like this (by ChatGPT):

from moviepy.editor import VideoFileClip

def split_video_by_4_seconds(input_file, output_folder): 
    video = VideoFileClip(input_file)
    duration = video.duration
    num_clips = int(duration // 4) + (1 if duration % 4 > 0 else 0)
    for i in range(num_clips):
        start_time = i * 4
        end_time = min((i + 1) * 4, duration)
        subclip = video.subclip(start_time, end_time)
        output_filename = f"{output_folder}/clip_{i + 1}.mp4"
        subclip.write_videofile(output_filename, codec="libx264")
    video.close()
    
input_file = "path/to/your/video.mp4" 
output_folder = "path/to/output/folder" 
split_video_by_4_seconds(input_file, output_folder)

Last updated