Nodes/CMK Flow/CMK FaceSwap Video Loader
ComfyUI Node

CMK FaceSwap Video Loader

One Node to Pick a Video, a Face, and Cut It Up

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK FaceSwap Video Loader
    • SEGMENTS
    • IMAGE SOURCE
    • LOG
    • diagnostic
    ◄MAX FRAMES 720P540►
    ◄MAX FRAMES 1080P240►
    ◄OVERLAP0.0►
    ◄VIDEO CODEClibx264►
    ◄VIDEO BITRATE8000k►
    ◄PRESETfast►
    ◄MEDIA SOURCES{"video":"","source":""}►

    Face-swapping video in ComfyUI usually starts with three nodes doing bookkeeping before anything interesting happens. This one collapses the bookkeeping: pick a video, pick a face photo, get a segmented project and an IMAGE of the source. That's it.

    What it actually does

    It's an input node for the pack's persistent video pipeline, and it's honest about being a wrapper - internally it delegates segment creation to CMK Split Video into Segments, unchanged, so segments, manifests and reuse behave exactly as they do in the general-purpose video workflow. What the loader adds is the pairing: a video and a source image chosen together, with the source named in the project metadata so downstream nodes - and the resume manifests - know which face that project was built against.

    Two selections ride in one widget. MEDIA SOURCES is a JSON string ({"video":"","source":""}) that the CMK frontend turns into a two-column picker. Videos are read from ComfyUI/input/video/, the source image from the normal input/ image path. If the source file isn't there, you get a clear SOURCE IMAGE not found error with the resolved path - not a silent empty tensor, which is the usual way this class of bug wastes an evening.

    Cutting the video up

    The splitter breaks long videos into segments, and the frame limits are resolution-aware because video VRAM cost isn't linear in duration:

    • MAX FRAMES 720P - default 540.
    • MAX FRAMES 1080P - default 240.
    • OVERLAP - default 0, up to 60 frames. Overlap exists so a face crossing a segment boundary isn't lost; it's also what lets the merge step stitch without a visible seam. Note this is frame overlap on top of however the split is otherwise computed.

    VIDEO CODEC (libx264 or hevc), VIDEO BITRATE (a string like 8000k) and PRESET (the whole x264 ladder, ultrafast through veryslow) are the encode settings, and they matter more than they look. Segments are decoded and re-encoded as they're produced, so you're not working from the master file - you're working from an encode of it. For a swap pass, libx264 at fast and a generous bitrate is the sane default; going veryslow here buys you nothing but a slower pipeline, because the swap is going to re-encode again on the way out.

    Outputs

    SEGMENTS is the CMK_VIDEO_SEGMENTS project context - the thing you hand to CMK FaceSwap Video. IMAGE SOURCE is the selected source face as a normal IMAGE, decoupled on purpose: the docstring is explicit that the source image is an independent native IMAGE transport and never becomes part of the segments context. So you can route it anywhere, including a generation-side identity node, without the video project knowing.

    LOG collects the run report, and this node is flagged as an output node in the graph sense - it always executes and it reports progress to the UI, which is why it's the sensible place to watch a long split happen rather than staring at a spinner. diagnostic carries the structured payload.

    Install

    Manager: search CMK Flow, install the CMKFlow entry, restart. Manually, from your ComfyUI root:

    git clone https://github.com/CMKFlow/cmk_nodes.git custom_nodes/cmk_nodes
    python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py
    python3 custom_nodes/cmk_nodes/scripts/check_cmk_resources.py --models-root "/path/to/ComfyUI-Shared"
    

    imageio-ffmpeg comes in through the pack's requirements, which is what gets you a working ffmpeg without hand-installing one. Model weights are not part of the package - for the swap you'll want inswapper_128.onnx and buffalo_l under ComfyUI/models/insightface, and the resource checker will find and offer to fetch them. As with the rest of the pack, ComfyUI's Nodes 2.0 / Vue setting needs to be on for the two-column media picker to render as intended.

    Where people get burned

    File placement. Videos go in ComfyUI/input/video/, not input/. Putting a clip in the wrong folder produces a "nothing in the dropdown" experience that looks like a bug and isn't.

    Frame limits versus expectations. A 1080p default of 240 frames isn't a hardware detection, it's a conservative budget. Raise it, but understand that you're choosing to make every downstream step - detection, swap, guard - run that much longer, on CPU-bound inference.

    Long first runs. Every segment's frames get pulled through ffmpeg and passed downstream. The first run of a project pays the full split cost; the manifests mean re-running it with an unchanged video is much cheaper. Don't conclude the node is slow from run one.

    CategoryCMK/Toolbox/Video

    Inputs (7)

    NameTypeDefaultDescription
    MAX FRAMES 720PINT5401–100000—
    MAX FRAMES 1080PINT2401–100000—
    OVERLAPFLOAT0.00–60—
    VIDEO CODECCOMBOlibx2642 options: libx264, hevc
    VIDEO BITRATESTRING8000k—
    PRESETCOMBOfast9 options: ultrafast, superfast, veryfast, faster, fast, medium, +3
    MEDIA SOURCESSTRING{"video":"","source":""}—

    Outputs (4)

    NameTypeDescription
    SEGMENTSCMK_VIDEO_SEGMENTS—
    IMAGE SOURCEIMAGE—
    LOGCMK_LOG_PIPE—
    diagnosticCMK_DIAGNOSTIC—