Nodes/KJNodes for ComfyUI/Decode and Save Video
ComfyUI Node Runs on cloud

Decode and Save Video

Decode long video straight to disk without OOMing

By kijai·Created 3 years ago·Updated 2 days ago· 3,011
Decode and Save Video
  • video_latent
  • video_vae
  • audio_latent
  • audio_vae
    fps25.00
    filename_prefixvideo/ComfyUI
    formatauto
    codecauto
    tiling

    The usual way to finish a video in ComfyUI is VAE Decode → a giant IMAGE batch sitting in memory → a combine node that muxes it into a file. That middle step is where long or high-res clips fall over: every decoded frame lives in RAM (and VRAM) at once, and a few hundred frames at 720p will happily eat all of it. DecodeAndSaveVideo skips the pileup. As its description says, it "decodes video frames and audio from latent representations, combines them, and saves as a video file, without keeping intermediate images in memory." Decode, write, move on - no giant image batch.

    It's from Kijai's KJNodes, and it fits the pattern of the pack's model-optimization side: small nodes that shave VRAM off the parts of a video workflow that blow up. For anyone doing Wan, Hunyuan, or LTX at length, this is the node that turns "out of memory on decode" into "it just finished."

    How it works

    Instead of decoding the whole latent into an image tensor and handing it off, it decodes in a streaming, tiled fashion and pipes frames to the encoder as it goes, so the full uncompressed sequence never coexists in memory. If your model also produces an audio latent, it decodes that too and muxes it into the same file. The result is a finished video on disk with far lower peak memory than the classic decode-then-combine chain.

    The inputs and outputs that matter

    • video_latent (LATENT) - the sampled video latent.
    • video_vae (VAE) - the VAE that matches your model. Get this right; a mismatched VAE gives you a smeared mess.
    • fps (default 25) - playback frame rate of the saved file.
    • filename_prefix (default video/ComfyUI) - where it lands under your output folder and what it's named.
    • tiling - the VRAM lever. If you're still tight on memory, this splits the decode spatially so even single frames don't need the whole card.
    • format / codec (both default auto) - leave on auto unless you have a specific container/codec need.
    • audio_latent / audio_vae (optional) - for models that generate sound, wire these to get audio muxed in.

    It's an output node - there are no outputs to wire onward. The file on disk is the deliverable, and that's deliberate.

    How to install it

    ComfyUI Manager: search KJNodes for ComfyUI, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kijai/ComfyUI-KJNodes
    pip install -r ComfyUI-KJNodes/requirements.txt
    

    then restart (portable: run pip through python_embeded\python.exe). Encoding to a video file leans on ffmpeg, which ComfyUI video workflows generally already have available.

    Common issues & troubleshooting

    You wanted the frames to keep working on them. This node has no IMAGE output - it goes straight to a file. That's the trade for the memory savings. If you need to upscale, interpolate, or composite after decode, this isn't your node; use a normal VAE Decode and accept the memory cost, or do that work before sampling.

    Still out of memory. Turn on tiling. The whole point is low peak memory, but a single 1080p+ frame can still be a lot; tiling breaks the spatial decode into pieces.

    Colors or motion look wrong. Usually a VAE mismatch - the video_vae has to be the one for your model. For Wan and similar, also remember the VAE compresses time, so your latent frame count isn't the decoded frame count 1:1.

    No audio in the file. You need both an audio_latent and the matching audio_vae wired in. If your model doesn't produce an audio latent, there's nothing to mux and the file is silent by design.

    CategoryKJNodes/image

    Inputs (9)

    NameTypeDefaultDescription
    video_latentLATENTThe latent representation of the video frames.
    fpsFLOAT25.000–999Frame rate for the output video.
    filename_prefixSTRINGvideo/ComfyUIThe prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes.
    formatCOMBOautoThe format to save the video as.
    codecCOMBOautoThe codec to use for the video.
    video_vaeVAEThe VAE model to use for encoding.
    tilingCOMBO2 options: [object Object], [object Object]
    audio_latentoptLATENTThe latent representation of the audio frames.
    audio_vaeoptVAEThe VAE model to use for decoding audio.

    Outputs (0)

    No outputs