Nodes/comfyui-pertineo-vfx/Pertineo Save Matte Sequence
ComfyUI Node

Pertineo Save Matte Sequence

Save Image Writes 8 Bits. Your Matte Needs 16.

By Pertineo·Created 8 days ago·Updated 8 days ago· 0
Pertineo Save Matte Sequence
  • alpha
    ◄output_folder►
    ◄filename_prefix►
    ◄start_frame1001►
    ◄frame_padding4►
    ◄format▾►
    ◄overwritetrue►
    ◄folder_suffix_matte►
    ◄source_folder—►

    You've just refinished a matte at 4K, hair and all, and you hand it to Save Image. Two things go wrong and only one of them is obvious.

    The obvious one: it writes 8-bit PNG. A matte is a smooth gradient - soft edges, motion blur, semi-transparent fabric. Eight bits is 256 levels, and in a comp those levels become visible banding across exactly the soft areas you spent VRAM on. The less obvious one: the file lands as prefix_00001_.png, numbered from 1, in your output folder, in ComfyUI's own naming scheme. Your plate says 1001. Your comp wants 1001. Nothing matches.

    Pertineo Save Matte Sequence exists to fix both: 16-bit PNG or 32-bit float EXR, with the frame numbering you tell it.

    What it does

    It takes a MASK batch and writes it out frame by frame as a numbered image sequence. Two formats, both lossless and float:

    • png (16 bit) - plenty for a matte, read back raw/linear by anything sensible.
    • exr (32 bit float) - the matte goes into R, G and B as well as A, which is how comp apps (Nuke, Natron, the Cattery nodes) expect a single-channel matte delivered.

    It's an output node - no outputs to wire, just alpha in and files on disk. And it has one genuinely clever trick: connect folder from Pertineo Load Image Sequence into source_folder and it writes a sibling folder named after the source. Source folder shot_v01 → output shot_v01_matte, and with an empty prefix the files inherit the name too: shot_v01.1001.png becomes shot_v01_matte.1001.png. On a shot with a real naming convention, that's five minutes of careful typing you don't have to do and can't get wrong.

    The inputs

    • alpha - the MASK batch. From the refiner, usually.
    • output_folder - where the sequence goes; created if it doesn't exist. Ignored entirely when source_folder is connected, which surprises people exactly once.
    • filename_prefix - <prefix>.<frame>.<ext>. Leave it empty if you're using source_folder and want the inherited naming. Without source_folder, an empty prefix falls back to alpha.
    • start_frame - the frame number of the first image in the batch. Default 1001. Match your plate. This is where Pertineo Frames for Model's first_frame output belongs, so the whole graph shares one numbering.
    • frame_padding - digits in the number: 4 gives 1001, and it's what you want unless your pipeline insists otherwise.
    • format - png (16 bit) or exr (32 bit float).
    • overwrite - on by default. Turn it off when you're rendering a fix into an existing sequence and only want the frames you deliberately re-run.
    • folder_suffix - _matte by default; used only alongside source_folder.

    Install

    ComfyUI Manager → Pertineo VFX, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/pertineo/comfyui-pertineo-vfx
    pip install -r comfyui-pertineo-vfx/requirements.txt
    

    OpenEXR>=3.2 is the pack's only dependency and it's the reason the EXR path works. The pack also switches on OpenCV's OpenEXR support as a fallback at import time. No models involved - this node has no weights to download.

    Where people get burned

    Reading your own 16-bit PNG back and thinking it's wrong. It's linear data in a 16-bit container. A viewer that applies an sRGB transform shows it washed out and mid-grey; a comp reading raw sees the correct matte. Load it back with Pertineo Load Image Sequence and mask_channel = red (or luminance) and it's exact - that output is never colour-converted.

    A numbering mismatch that only shows up in the comp. Batch frame 1 is written as frame start_frame. If your plate starts at 1001 and you left start_frame at 1001 but your batch actually came from frames 1031 onward, your matte is now 30 frames early and perfectly smooth about it. This is the number to wire, not to type.

    Turning overwrite off and then wondering where the new frames went. Off means existing files are kept - including the bad ones. If you're iterating on one frame, either bump the suffix/prefix or clear the old file.

    Connecting source_folder and expecting output_folder to still apply. It doesn't; the sibling folder wins. Deliberate, documented, still catches people.

    On a real shot this node is unglamorous and load-bearing: it's the point where your ComfyUI graph stops being a graph and becomes deliverable frames.

    CategoryPertineo/IO

    Inputs (9)

    NameTypeDefaultDescription
    alphaMASKMatte batch to write.
    output_folderSTRINGOUTPUT – folder the sequence is written to. Created if it does not exist. Ignored when source_folder is connected.
    filename_prefixSTRINGFile name: <prefix>.<frame>.<ext>. Leave empty to name the files after the source sequence plus folder_suffix (needs source_folder), e.g. shot_v01_matte.1001.png. Without source_folder an empty prefix becomes 'alpha'.
    start_frameINT10010–10000000Frame number of the first image in the batch (match your plate numbering).
    frame_paddingINT41–8Digits of the frame number (4 = 1001, 0001).
    formatCOMBOPNG 16 bit (read as raw/linear) or EXR 32-bit float (alpha in R, G, B and A).
    overwriteBOOLEANtrueOverwrite existing files. Off = existing frames are kept.
    folder_suffixSTRING_matteOnly used when source_folder is connected: the output folder is named <source folder name><suffix> next to the source (shot_v01 -> shot_v01_matte); with an empty filename_prefix the files get <source name><suffix> as well.
    source_folderoptSTRINGConnect 'folder' from Pertineo Load Image Sequence: the matte is then written to a sibling folder <source folder><folder_suffix> and output_folder is ignored.

    Outputs (0)

    No outputs