Nodes/ComfyUI-FunPack/FunPack Save Video
ComfyUI Node

FunPack Save Video

Stop paying libx264's single-threaded tax at the end of every run

By digital-garbage·Created about a year ago·Updated about 13 hours ago· 20
FunPack Save Video
  • images
  • audio
    ◄fps24.00►
    ◄filename_prefixFunPack►
    ◄encoderauto►
    ◄codech264►

    You've just spent eight minutes rendering a clip. And then, right at the end, the save node sits there for another thirty seconds doing something that should be nearly free. If you've ever watched that and wondered why, the answer is in this node's source comment: ComfyUI's stock SaveVideo encodes through libx264 via PyAV, and FFmpeg's library default is one thread. On your desktop with a decent clock speed you barely notice. On a rental with a cheap CPU allocation, that single thread is where the tail of the run goes.

    FunPack Save Video exists to fix that. If your card and your PyAV build have an encoder, NVENC does the work on the GPU. If they don't, libx264 runs on every core instead of one.

    What it does

    Frames in, MP4 out, straight to ComfyUI's output folder. No CreateVideo step in between - you feed it the images batch and, optionally, the audio, and it muxes both.

    The encode path: frames are clamped to bytes and moved to CPU numpy, then PyAV opens an MP4 with use_metadata_tags+faststart - the workflow metadata is written in, and the index goes at the front of the file so the preview player can seek without downloading the whole thing. Video for H.264 on GPU is h264_nvenc at preset p5 in constant-quality mode at 23, which is deliberately matched to libx264's default CRF so you're not choosing quality by accident. Audio, when present, is AAC and is added before the first frame is written, because the MP4 header is fixed at that point.

    H.265 gets one detail worth knowing about: the node tags the stream hvc1 rather than the default hev1, because Safari and Chrome on a Mac refuse the latter. That's the kind of thing you only learn from shipping video on the web.

    Frames plus sound, one node, sensible defaults. That's the whole pitch.

    The inputs you'll actually set

    Required: images, fps, filename_prefix. The prefix defaults to FunPack, and a counter is appended to each file (FunPack_00001_.mp4), so repeat runs don't overwrite each other.

    Optional: audio - leave it out and you get a silent MP4, which is exactly right for a clip you'll lay sound onto later. encoder is the one meaningful choice: auto (GPU if available, otherwise CPU), gpu (fail rather than use the CPU), cpu (libx264 on all cores). codec is h264 or h265, and it only applies to the GPU path - the tooltip is blunt about the tradeoff: H.264 plays everywhere, H.265 makes smaller files but Firefox may not play it.

    There are no output sockets. It's an output node: it writes into ComfyUI/output and hands the result back as a preview, and the workflow is embedded in the file the same way a PNG's is - take it with you if you share the clip, since anything that re-encodes it will strip the metadata.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/digital-garbage/ComfyUI-FunPack
    cd ComfyUI-FunPack && pip install -r requirements.txt
    

    Restart ComfyUI. ComfyUI Manager installs the pack by searching ComfyUI-FunPack, though the README notes Registry publishes lag behind git - Settings ▸ About FunPack in the /funpack/ UI is the honest way to see what version you're on.

    A dependency note, because the README and the code tell slightly different stories here. requirements.txt lists comfy-kitchen>=0.2.32 and gguf, and nothing about video encoding. That's because the node imports PyAV - and PyAV is already a ComfyUI core dependency for ComfyUI's own video nodes. So you don't install anything extra; if av were missing, this module wouldn't import at all. No ffmpeg CLI binary is needed either, since PyAV bundles the libraries.

    Common issues

    this PyAV build has no NVENC encoder. You set encoder to gpu and your PyAV wasn't compiled with NVIDIA's encoders, or the card isn't one with NVENC. Switch to auto or cpu. Note that auto doesn't shout about this - it logs a one-time alert and quietly saves on the CPU, which is the right behaviour for a batch render and also why you might not notice you never got GPU encoding.

    the GPU encoder (NVENC) failed. Same family of problem, different cause: driver refusal, codec unsupported at your resolution, session limit hit. The node deletes the half-written file before raising, so you won't find a corrupt MP4 lying around, and in auto mode it falls back to CPU instead of raising.

    The clip is the wrong length or plays fast. fps here has to match what the model produced and what you told any Cut Opening node. Nothing in the graph checks that for you.

    H.265 doesn't play in a browser. Known and documented by the author. Use H.264 for anything you're going to look at in a browser; H.265 is a file-size play for archival or for Chrome/Safari viewers.

    The node is missing entirely. FunPack v5 loads each feature as a module and skips any that fail to load. A missing node means the module errored during startup - check the console at launch, and if av is in the traceback, that's your answer.

    CategoryFunPack/Output

    Inputs (6)

    NameTypeDefaultDescription
    imagesIMAGE—
    fpsFLOAT24.001–240—
    filename_prefixSTRINGFunPack—
    audiooptAUDIO—
    encoderoptCOMBOautoauto: GPU (NVENC) if available, else H.264 on the CPU. gpu: fail rather than use the CPU. cpu: H.264 (libx264) on every core.
    codecoptCOMBOh264For the GPU encoder. H.264: plays in every browser. H.265: smaller files, but Firefox may not play it.

    Outputs (0)

    No outputs