Earngenix Logo
Skip to main content

ComfyUI Workflow Blog · Intermediate

How to Replace a Character in a Video With ComfyUI (SCAIL-2)

Swap a tracked person in your video with a reference character using SCAIL-2's Replacement Mode — full model list, folder setup, workflow download, and node-by-node settings.

~32.8GB

Diffusion model

RTX 4090

Tested on

Intermediate

Skill level

Replacement

Mode

By Earngenix Team · · Tested on RTX 4090 (24GB VRAM)

⚡ Quick Answer

SCAIL-2's Replacement Mode swaps a person in your video with a reference character image, keeping the original motion, framing, and scene intact. It tracks both the original person and your reference character with SAM3.1, then generates the replacement using the LightX2V distill LoRA and the SCAIL-2 DPO LoRA for cleaner hands and lip sync. The diffusion model is ~32.8GB (fp16) — tested on an RTX 4090 (24GB) with automatic offloading.

SCAIL-2 has two modes. Motion Transfer takes a still photo and makes it perform a video's motion — see the SCAIL-2 Motion Transfer guide if that's what you're after. Replacement Mode does something different: it finds a real person already in your video and swaps them out for your reference character, frame by frame, while everything else in the scene stays the same.

This guide covers Replacement Mode only — the models, folder setup, workflow download, and settings specific to it.

What Is SCAIL-2 Replacement Mode?

Motion Transfer tracks one subject — your reference image — and animates it. Replacement Mode tracks two: the person already in your driving video, and your reference character. SAM3.1 builds a separate mask for each, and SCAIL-2 uses both to know exactly who to remove and who to put in their place.

This workflow is built from a subgraph — a self-contained group of nodes ComfyUI displays as a single block with exposed inputs, instead of dozens of separate nodes you wire by hand. You only touch the settings ComfyUI exposes on the outside of the block.

Warning: This workflow requires a specific ComfyUI update — PR#14373 — since subgraphs of this kind are a newer ComfyUI feature. If the workflow fails to load correctly, update ComfyUI to the latest version first.
Not interchangeable: Replacement Mode and Motion Transfer use a different mask configuration entirely. Don't try to toggle one workflow between the two — use the correct downloaded workflow for the mode you want.

What the Output Looks Like

Both examples below use the settings baked into this workflow: 512×896, 121 frames, replace_mode: True, with the SAM3 tracking prompt set to human on both the driving video and the reference image.

🎬 Example 1

512×896 · 121 frames · replace_mode: True · RTX 4090

Reference Character

Reference character image used for SCAIL-2 Character Replacement, Example 1🔍 Click to zoom

Driving Video (Original)

SCAIL-2 Output (Replaced)

🎬 Example 2

[resolution] · [frame count] · replace_mode: True · RTX 4090

Reference Character

Reference character image used for SCAIL-2 Character Replacement, Example 2🔍 Click to zoom

Driving Video (Original)

SCAIL-2 Output (Replaced)

Tip: Use one clean, unobstructed reference photo per example — a 1:1 or portrait-ratio image with the full character visible transfers clothing and identity detail more accurately than a cropped or low-resolution reference.

What You Need Before Starting

Tested on

RTX 4090 (24GB VRAM)

Diffusion model size

~32.8GB (fp16)

Warning: wan2.1_14B_SCAIL_2_fp16.safetensors is roughly 32.8GB on disk — larger than a 24GB GPU's VRAM. ComfyUI automatically offloads part of the model to system RAM to run it, but expect noticeably slower generation than a model that fits fully in VRAM. This is a heavier load than the fp8_scaled file used in the Motion Transfer guide — don't assume the same VRAM figure applies here.

The full model list with download links is in the Download the Models section below.

Download the Models

Seven files across five folders. Click a filename to jump to its download link, or use the table below to grab everything at once.

FolderFileNotes
checkpointssam3.1_multiplex_fp16.safetensorsSAM3.1 — tracks the original person and the reference character↗ Download
clip_visionclip_vision_h.safetensorsReads your reference image↗ Download
diffusion_modelswan2.1_14B_SCAIL_2_fp16.safetensorsThe SCAIL-2 checkpoint, full precision (~32.8GB)↗ Download
loraslightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensorsDistill LoRA — fast sampling (strength 0.8 in this workflow)↗ Download
loraswan2.1_SCAIL_2_DPO_lora_bf16.safetensorsFixes hand distortion, improves lip/eye sync (strength 1)↗ Download
text_encodersumt5_xxl_fp8_e4m3fn_scaled.safetensorsReads your text prompt↗ Download
vaeWan2_1_VAE_bf16.safetensorsDecodes the output into pixels↗ Download

All files hosted on HuggingFace — see the SCAIL-2 model card ↗ and the official SCAIL-2 GitHub repository ↗ for architecture details.

Where to Place the Files

ComfyUI uses a specific folder structure inside its models/ directory. Placing a file in the wrong folder means ComfyUI cannot find it and the workflow fails to load.

ComfyUI/
└── models/
    ├── checkpoints/
    │   └── sam3.1_multiplex_fp16.safetensors
    ├── clip_vision/
    │   └── clip_vision_h.safetensors
    ├── diffusion_models/
    │   └── wan2.1_14B_SCAIL_2_fp16.safetensors
    ├── loras/
    │   ├── lightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensors
    │   └── wan2.1_SCAIL_2_DPO_lora_bf16.safetensors
    ├── text_encoders/
    │   └── umt5_xxl_fp8_e4m3fn_scaled.safetensors
    └── vae/
        └── Wan2_1_VAE_bf16.safetensors

Already have wan2.1_14B_SCAIL_2_fp8_scaled.safetensors from the Motion Transfer guide? That's a different precision than the fp16 file above — don't substitute one for the other without testing, since Replacement Mode's dual-mask conditioning may behave differently at fp8.

Never installed ComfyUI Manager or fixed a red-node error before? See how to install missing custom nodes in ComfyUI first.

Download the Workflow

This is the ready-to-use ComfyUI workflow JSON, preloaded with the Base and Extend subgraphs for SCAIL-2 Character Replacement. Drag it onto the canvas and generate.

SCAIL-2 Character Replacement — Workflow JSON

Includes the Base subgraph and one Extend subgraph for long videos.

Download Workflow

How to Load the Workflow JSON into ComfyUI

  1. Download the .json file to your computer.
  2. Open ComfyUI in your browser.
  3. Drag the file directly onto the ComfyUI canvas.
  4. The workflow loads. Red-bordered nodes mean a custom node is missing.
  5. If you see red nodes, click ManagerInstall Missing Custom Nodes, then restart ComfyUI completely.

How to Run the SCAIL-2 Character Replacement Workflow

1

LoadVideo

Upload your driving video — the clip containing the person you want to replace.
2

LoadImage

Upload your reference character image — who replaces that person.
3

Set the Base subgraph parameters

  • prompt — describes the final output, e.g. "a girl is doing kungfu with the stick." Separate from the SAM3 tracking prompts below.
  • replace_modeTrue for Replacement (this workflow's default).
  • segment_index1 for the first (or only) segment.
  • width / height — must be multiples of 32. 512 × 896 in this workflow.
  • frame_count121 in this example.
  • previous_frame_count — overlap frames carried into the next segment. 5 by default.
  • sam3_video_object / sam3_image_object — SAM3.1 tracking prompts, not the main prompt. Default human for both.
  • turbo_mode — leave True for the fast LightX2V-distilled preset.
  • Model dropdowns — confirm each points to the file names in the table above.
4

Run the Base subgraph

For a clip short enough to finish in one segment, this is your final output — skip straight to Save Video.
5

SaveVideo

Two save nodes exist: one for the first-segment output, one for the final stitched output. For single-segment videos, both contain the same result.
Exposed Base subgraph widget panel showing prompt, replace_mode, width, height, and SAM3 tracking fields🔍 Click to zoom
Screenshot: the exposed Base subgraph widget panel.
SAM3_VideoTrack and SCAIL2ColoredMask nodes connected inside the Base subgraph🔍 Click to zoom
Screenshot: SAM3.1 dual-role tracking and colored mask nodes, inside the subgraph.

Want the deeper mechanics of how a LoRA modifies a base model? See the ComfyUI LoRA guide.

How Long Videos Work (Base + Extend Segments)

A single segment tops out around 76 usable frames (frame_count minus the previous_frame_count overlap). For anything longer, this workflow chains additional Extend subgraphs, each picking up where the last one left off.

The template includes a built-in calculator for this — a segment-count group that runs ceil(total_frames / 76) on your driving video and previews the result as text.

Segment-count preview node showing the calculated number of segments needed for a long driving video🔍 Click to zoom
Screenshot: the built-in segment-count calculator.

To Extend a Video:

  1. Duplicate the Extend subgraph for each additional segment.
  2. Feed the previous segment's output into the new one's previous_frames input.
  3. Increment segment_index by 1 each time (2, 3, 4...).
  4. Run each segment manually — there's no auto-loop. Queue Base, wait for it to finish, then queue the next Extend, and so on.
  5. Once every segment has run, the workflow's batching and video-combine nodes stitch them into one final video automatically.
Tip: Preview the segment-count calculator before you commit to a long driving video — if it comes back higher than 3–4 segments, consider trimming your source clip instead, since each segment is a full generation pass at whatever your per-segment time turns out to be on your GPU.

Why the DPO LoRA Matters

Replacement Mode leans harder on this LoRA than Motion Transfer does, because swapping a whole person into someone else's motion is a harder generation task than animating a single photo — hands and faces are where it most commonly breaks. The DPO LoRA specifically targets hand distortion and improves how well the character's lips and eyes stay in sync with the original performance.

If you skip it, expect more visible artifacts around the hands and face in your output.

Troubleshooting

Subgraph nodes appear as one block with no visible internals

This is expected — Base and Extend are subgraphs, not individual nodes. Double-click the block to expand it and see the nodes inside if you need to debug further.

Workflow won't load, or subgraph inputs look wrong

You're likely on a ComfyUI version older than PR#14373. Update ComfyUI to the latest version before troubleshooting further.

Wrong person got replaced in a crowded scene

SAM3.1 locked onto the wrong subject when multiple people are in frame.

  1. Tighten your tracking prompt to describe the specific person (e.g. "man in red jacket" instead of "human").
  2. Preview the SAM3_VideoTrack output before running the full sampler — confirm the correct person is highlighted.
  3. For scenes with several people, isolate the target by object ID rather than a generic prompt.

Extended video has a visible seam or jump between segments

Check that previous_frames on the Extend subgraph is actually wired to the prior segment's output, and that previous_frame_count (5 by default) matches on both. A mismatch here is the most common cause of a visible jump at the segment boundary.

CUDA out of memory

Most common at higher frame counts or resolutions with the full fp16 checkpoint.

  1. Lower the frame length in the Base subgraph.
  2. Shorten your driving video to 3–5 seconds first, then scale up once it runs.
  3. If installed, confirm SageAttention is enabled to reduce memory overhead — see the SageAttention install guide.

Reference character doesn't blend into the scene (lighting mismatch)

The generated character looks pasted in rather than lit by the original scene.

  1. Check that your reference image's lighting is reasonably close to the driving video's.
  2. Consider the official Relighting LoRA from the SCAIL-2 repository — it's built specifically to blend a replacement character into the target video's lighting and shadows.
  3. Lower reference emphasis slightly if the character looks over-stylized against the background.

Frequently Asked Questions

It's the mode of the SCAIL-2 checkpoint that swaps a person already in your video with a different reference character, rather than animating a still image with motion from a separate video.

Motion Transfer takes a reference photo and makes it perform a driving video's motion from scratch. Replacement Mode finds an existing person in the video and replaces them, keeping the rest of the scene untouched.

It isn't strictly required to run the workflow, but skipping it means more visible hand distortion and weaker lip/eye sync in the output.

The fp16 diffusion model is roughly 32.8GB on disk — larger than most single-GPU VRAM budgets. ComfyUI automatically offloads part of the model to system RAM, so it can run on a 24GB card, but expect slower generation than a model that fits fully in VRAM.

Yes — add an additional SAM3_VideoTrack and matching reference image per additional person, and confirm each gets its own colored mask region from SCAIL2ColoredMask.

No. Only clips long enough to need more than one segment require the Extend subgraph. Check the built-in segment-count preview first — if it returns 1, the Base subgraph alone is your final output.

What to Do Next

Download the workflow and run it with the defaults first.

Once you get a clean replacement on a short clip, swap in your own reference image and driving video, then use the troubleshooting section to tighten your tracking prompt for busier scenes.

Published: 2026-07-29 · Last updated: 2026-07-29 · Tested on RTX 4090 (24GB VRAM) · Model: wan2.1_14B_SCAIL_2_fp16.safetensors

Discussion

Join the discussion

Sign in to leave a comment or reply

💬

No comments yet

Be the first to share your thoughts!