Nodes/ComfyUI-Handwriting-Video-Replace/Handwriting Video Replace
ComfyUI Node

Handwriting Video Replace

Your text, written in ink on a moving red-paper video — tracking and all

By hyt131331-creator·Created 3 months ago·Updated 3 months ago· 0
Handwriting Video Replace
    • video_path
    line_one嘻嘻嘻
    line_two20060804
    font_size36
    font_color#000000
    max_seconds23.000
    text_seconds0.000
    fade_seconds0.120
    output_fps60
    text_positionbottom-center

    The name overpromises in one direction and underpromises in another. This node does no AI - no model, no inference, no API key, nothing to download beyond the repo. What it actually does is cleverer than most "text on video" tools: it takes the ~50-second template video that ships with the pack (a hand writing on a sheet of red paper, camera moving), finds the red paper in every frame, tracks it as it shifts, and stamps your two lines of text onto it - warped to follow the paper and blended to look like real ink. Out comes a finished MP4, template audio still on it.

    Why reach for it? It's a one-trick content node for the "handwriting on red paper" clip that's everywhere in Chinese short video - the defaults (嘻嘻嘻, 20060804) are straight out of that genre. If that look is what you need and you don't want to hand-build the tracking pipeline, this is the whole thing in a single node. The flip side: there is no video input. It always uses the bundled fixed_template.mp4, so you get this one hand and this one paper, and that's that.

    How it works

    The renderer is real OpenCV plumbing, and it's better than this pack's reputation suggests. Each frame, HSV color detection finds the red paper (two red bands plus a pink band, contoured down to a quad). Then Lucas-Kanade optical flow on good-features points, solved with a RANSAC homography (affine as fallback), tracks that quad through the camera shake. The tracked quad gets smoothed, and if tracking is lost it re-detects; if the paper genuinely leaves frame, it locks the text off rather than spraying it over the background.

    Your text is rendered with the bundled handwriting font, perspective-warped onto the tracked quad, clipped to the paper's visible surface, and blended with an ink trick: it darkens the paper under the text using local luminance as texture and caps opacity around 0.76, so it reads as written-on rather than sticker-placed. A fixed jump cut baked into the source (~10.5s in) gets skipped, and ffmpeg muxes the silent render with the template's audio - libx264, yuv420p, AAC, faststart.

    The inputs that actually matter

    • line_one / line_two - the two lines of text. The bundled font handles Chinese out of the box, which is the point of this pack.
    • font_size (12–160, default 36) and font_color (hex, default #000000). Side note: feed it a malformed hex string and it silently falls back to white - one of those defaults that only bites when you mean it to.
    • max_seconds (default 23, max 300) - how much of the ~50s template to render. This is the one to change if 23 seconds isn't enough.
    • text_seconds (default 0) and fade_seconds (default 0.12) - with text_seconds at 0 the text stays for the whole clip. Set it to a positive number and the text vanishes partway, fading over the final fade_seconds.
    • text_position - bottom-center, center, or top-center.

    The single output, video_path, is a STRING: the path to the MP4, written to the OS temp directory under comfyui_handwriting_video_outputs/. The node is an output node, so it always runs and prints that path in the UI. Two consequences worth knowing: it is not in ComfyUI's output/ folder, and it lives in temp, so it won't survive a reboot. Point something at the path (a video loader/preview node, or just grab the file) while your session is alive.

    Installing and the gotchas

    ComfyUI Manager (search "ComfyUI-Handwriting-Video-Replace") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hyt131331-creator/ComfyUI-Handwriting-Video-Replace
    

    Dependencies are opencv-python, Pillow, numpy, imageio-ffmpeg - Manager installs them from requirements.txt; a manual clone won't, so run pip install -r ComfyUI-Handwriting-Video-Replace/requirements.txt. You also need a real ffmpeg binary: it tries system ffmpeg, then the one bundled with imageio-ffmpeg, and throws ffmpeg is required to create browser-compatible MP4 output if neither exists. No model files at all. It's built for RunningHub's cloud ComfyUI, where you'd request the node be installed rather than cloning it yourself.

    Where people get burned:

    • Font file not found: .../assets/aaa.TTF - the most likely first-run failure. The README promises a bundled assets/aaa.TTF, but the repo doesn't actually contain it, and the renderer hard-requires it at render time. If your clone is missing it, you're dropping a TTF there (or patching the path in renderer.py) before anything renders.
    • Missing dependency after a manual clone - run the pack's Env Check node first; it tells you exactly which import failed.
    • Text flickers or vanishes - that's tracking loss or the paper leaving frame; the node intentionally locks text off rather than pasting it over the background.

    Reality check: single commit, one author, zero impressions on comfy.icu, no license file. It's a throwaway marketplace pack - perfectly fine for its one trick, not something to build a serious pipeline on. But for that trick, the tracking is genuinely well done.

    CategoryVideo/Handwriting

    Inputs (9)

    NameTypeDefaultDescription
    line_oneSTRING嘻嘻嘻
    line_twoSTRING20060804
    font_sizeINT3612–160
    font_colorSTRING#000000
    max_secondsFLOAT23.0001–300
    text_secondsFLOAT0.0000–300
    fade_secondsFLOAT0.1200–2
    output_fpsFLOAT608–60
    text_positionCOMBObottom-center3 options: bottom-center, center, top-center

    Outputs (1)

    NameTypeDescription
    video_pathSTRING