ComfyUI > Nodes > Facefusion_comfyui > FF API: Swap Face (Video)

ComfyUI Node: FF API: Swap Face (Video)

Class Name

SwapFaceVideo

Category
FaceFusion API
Author
huygiatrng (Account age: 2009days)
Extension
Facefusion_comfyui
Latest Updated
2025-11-30
Github Stars
0.04K

How to Install Facefusion_comfyui

Install this extension via the ComfyUI Manager by searching for Facefusion_comfyui
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Facefusion_comfyui in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

FF API: Swap Face (Video) Description

Facilitates realistic face swapping in videos with advanced detection and customization.

FF API: Swap Face (Video):

The SwapFaceVideo node is designed to facilitate the process of face swapping within video content, providing a seamless and efficient way to replace faces in video frames with those from a source image. This node is particularly beneficial for AI artists and content creators who wish to experiment with face swapping in their video projects, offering a high degree of customization and control over the swapping process. By leveraging advanced face detection and swapping models, the node ensures that the face replacement is both realistic and contextually appropriate, maintaining the integrity of the original video while introducing new facial elements. The node's capabilities extend to handling various face mask types and regions, allowing for precise control over which parts of the face are swapped, and it can process videos with multiple faces, selecting the appropriate face based on user-defined criteria. This makes it an invaluable tool for creative projects that require dynamic and flexible face manipulation in video content.

FF API: Swap Face (Video) Input Parameters:

source_images

This parameter represents the source image(s) from which the face(s) will be extracted for swapping into the target video. It can handle multiple images if provided in a batch, allowing for batch processing of face swaps. The source image should ideally be of high quality to ensure a realistic swap. There are no explicit minimum or maximum values, but the image should be clear and well-lit for optimal results.

target_video

The target video is the video content where the face swap will be applied. It should be provided as a VideoFromComponents object, which includes both the video frames and audio. The video should be of a format and resolution that the node can process efficiently.

api_token

This is a string token used for authentication purposes when accessing certain face swapping models or APIs. It ensures that the node can securely interact with external services if required. The token should be valid and active to avoid authentication errors.

face_swapper_model

This parameter specifies the model used for the face swapping process. It determines the algorithm and approach used to replace faces in the video. The choice of model can affect the quality and speed of the swap, with different models offering various trade-offs between realism and computational efficiency.

face_detector_model

The face detector model is used to identify and locate faces within the video frames. It is crucial for ensuring that the correct faces are targeted for swapping. The model should be chosen based on its accuracy and compatibility with the video content.

pixel_boost

This parameter enhances the pixel quality of the swapped face, ensuring that it blends seamlessly with the surrounding video content. It is a string value that can be adjusted to improve the visual quality of the swap, with higher values potentially increasing processing time.

face_occluder_model

The face occluder model helps manage occlusions, such as hair or glasses, that might interfere with the face swap. It ensures that these elements are appropriately handled to maintain the realism of the swap. The model should be selected based on its ability to handle the specific occlusions present in the video.

face_parser_model

This model is used to parse and understand the different regions of the face, allowing for more precise and targeted swapping. It is essential for ensuring that the swap respects the natural boundaries and features of the face.

face_mask_blur

A float value that determines the amount of blur applied to the face mask edges, helping to blend the swapped face with the original video content. A higher blur value can help smooth transitions but may also reduce detail.

face_selector_mode

This string parameter defines the mode of face selection, determining whether all faces or a specific face in the video should be swapped. Options typically include modes like 'single' or 'many', allowing for flexible face selection based on the project's needs.

face_position

An integer that specifies the position of the face to be swapped when multiple faces are detected. It helps in selecting the correct face in scenarios where the video contains several faces.

sort_order

This parameter determines the order in which faces are processed, which can be important when multiple faces are present. It affects the sequence of face swapping operations and can be adjusted to prioritize certain faces.

score_threshold

A float value that sets the threshold for face detection confidence. Only faces with a detection score above this threshold will be considered for swapping, ensuring that only confidently detected faces are processed.

use_box_mask

A boolean parameter that indicates whether a box mask should be used for face swapping. It provides a simple rectangular mask around the face, which can be useful for straightforward swaps.

use_occlusion_mask

This boolean parameter specifies whether an occlusion mask should be used, helping to manage elements that might obscure the face, such as hair or accessories.

use_area_mask

A boolean that determines if an area mask should be applied, allowing for more targeted face swapping by focusing on specific facial areas.

use_region_mask

This boolean parameter indicates whether a region mask should be used, enabling precise control over which facial regions are included in the swap.

face_mask_areas

A string that lists the areas of the face to be masked, such as 'upper-face', 'lower-face', or 'mouth'. It allows for detailed control over the face swap process by specifying which parts of the face are affected.

face_mask_regions

This string parameter specifies the regions of the face to be masked, such as 'skin', 'nose', or 'mouth'. It provides additional granularity in controlling the face swap.

face_mask_padding

A string that defines the padding around the face mask, specified as 'top,right,bottom,left'. It allows for adjustments to the mask size, ensuring that the swap covers the desired facial area.

max_workers

An integer that sets the maximum number of worker threads used for processing, affecting the speed and efficiency of the face swap. A higher number of workers can increase processing speed but may also require more computational resources.

reference_image

An optional tensor that can be used as a reference for the face swap, helping to guide the process and ensure consistency with a specific facial appearance.

reference_face_distance

A float value that sets the distance threshold for matching faces with the reference image, ensuring that only similar faces are swapped. It helps maintain consistency in the face swap process.

FF API: Swap Face (Video) Output Parameters:

output_video

The output of the SwapFaceVideo node is a VideoFromComponents object, which includes the video frames with the swapped faces and the original audio. This output video reflects the changes made during the face swap process, providing a seamless integration of the new faces into the original video content. The output is designed to maintain the quality and integrity of the original video while incorporating the desired face swaps.

FF API: Swap Face (Video) Usage Tips:

  • Ensure that the source image is of high quality and well-lit to achieve the best results in face swapping.
  • Adjust the face_mask_blur parameter to blend the swapped face smoothly with the original video content, especially if the lighting conditions vary.
  • Use the face_selector_mode to control whether all faces or a specific face in the video should be swapped, depending on your project's requirements.
  • Experiment with different face_swapper_model and face_detector_model options to find the best balance between speed and quality for your specific video content.

FF API: Swap Face (Video) Common Errors and Solutions:

"No faces in face_data to swap"

  • Explanation: This error occurs when no faces are detected in the target video frames, preventing the face swap process from proceeding.
  • Solution: Ensure that the video content is clear and that the face detector model is correctly configured to recognize faces in the video.

"Face index out of range"

  • Explanation: This error indicates that the specified face index exceeds the number of detected faces in the video.
  • Solution: Verify the number of faces detected and adjust the face_position parameter to a valid index within the range of detected faces.

"NSFW content detected in target video"

  • Explanation: The node has detected potentially inappropriate content in the video, triggering a content filter.
  • Solution: Review the video content for any inappropriate material and consider using a different video or adjusting the content filter settings if applicable.

FF API: Swap Face (Video) Related Nodes

Go back to the extension to check out more related nodes.
Facefusion_comfyui
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.