Nodes/LanPaint/LanPaint Video Mask Editor
ComfyUI Node

LanPaint Video Mask Editor

Paint masks straight onto your video — and even ship them inside the mp4

By scraed·Created about a year ago·Updated 7 days ago· 1,338
LanPaint Video Mask Editor
    • video
    • mask
    • audio_mask
    video
    keyframes{}
    audio_mask[]

    Masking a video frame-by-frame is the most tedious thing you can do in ComfyUI. LanPaint_VideoMaskEditor is LanPaint's answer: pick your video, hit "Edit Video Mask," and paint masks on keyframes while the node automatically morphs them across every frame in between - with a live preview showing exactly what the sampler will see. And on top of that, it handles audio, because the newer LanPaint pipeline inpaints sound too.

    This is the front door to LanPaint's video and AV inpainting. The pack's video support runs on Wan 2.2 (video-only, up to around 40 frames before things get slow and unstable), and on MiniMax H3 for video plus audio. Whatever your target, this node is where the mask gets born.

    How it works

    It behaves like a LoadVideo node - you pick a file and it hands back a VIDEO reference with no pixel decoding - but it also outputs two masks. The frontend editor streams the same file: you scrub to a keyframe, paint a mask, scrub to another, paint again, and the frames between them get a signed-distance-field (SDF) interpolation. That's the good part: instead of cross-fading one blob into another (which gives you mushy gray in-between masks), the SDF slides the zero level set between the two shapes, so edges stay sharp while the mask translates, grows, or splits. What you see in the preview is exactly what the backend produces.

    The audio mask is built the same session: drag intervals on the waveform, and the editor writes them out as a hard 0/1 tensor at the video's frame rate. Both masks follow the LanPaint convention: 1 = regenerate, 0 = keep. Frames before your first keyframe or after your last one get no mask at all - all zeros - which is worth knowing if your masked region should cover the whole clip.

    There's a genuinely neat trick on top: the editor's "Export mask video" button remuxes a new <name>_masked.mp4 with the masks embedded in the file's metadata (the original is never touched). Share that single file and whoever loads it in the editor gets the masks back automatically.

    The inputs that matter

    • video - the source file (mp4, webm, mov, and friends), picked from your input folder or uploaded.
    • keyframes and audio_mask - hidden widgets, marked "written by the mask editor." Don't hand-edit them; they're bookkeeping.

    Outputs are video (the file, unchanged), mask (per-frame [F, H, W] video mask), and audio_mask (per-frame [F] audio mask). The masks feed AVEncode or SetLatentNoiseMask; the video reference feeds the same nodes.

    Install

    It's part of the LanPaint pack: ComfyUI Manager → search "LanPaint", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/scraed/LanPaint
    

    then restart. The video-output types need a recent ComfyUI runtime (the pack requires > 0.3.11), and two optional libraries do heavy lifting if present: PyAV for reading/writing the mask metadata in mp4s, and scipy for the fast SDF interpolation - the code falls back to pure Python if they're missing, so install isn't blocked either way.

    Where people get burned

    The obvious one: no audio track means no audio waveform, and if you never paint any keyframes the video mask comes out all zeros - which is the same as "keep everything," so you'll get an untouched video with a confusingly long render. And keep video inpainting short: the README is blunt that 40 frames is the comfortable ceiling and 81 frames will take sixteen minutes and eat ~43 GB of VRAM on a test rig - most of that is the model, not LanPaint, but the editor can't save you from that part.

    Categoryvideo

    Inputs (3)

    NameTypeDefaultDescription
    videoCOMBOSource video file. Returned as the video output and used by the mask editor preview.
    keyframesSTRING{}Hidden: keyframe mask files {"frame": "file.png"}. Written by the mask editor.
    audio_maskSTRING[]Hidden: audio inpainting intervals [{"start": s, "end": e}] in seconds. Written by the mask editor.

    Outputs (3)

    NameTypeDescription
    videoVIDEO
    maskMASK
    audio_maskMASK