Description
The Decode and Save Video node decodes video frames and optional audio from latent representations, combines them, and saves the resulting video directly to a file. It is designed for memory efficiency: decoded frames are written to disk on-the-fly without storing all intermediate images in RAM. This makes it suitable for long or high-resolution videos that would otherwise exceed available memory.
The node expects a latent representation of the video frames (typically produced by a video diffusion model) and an optional latent representation of the audio. Two separate VAE models must be provided: one for decoding the video latent (video_vae) and one for decoding the audio latent (audio_vae – required only if an audio_latent is supplied). The node also supports tiled decoding (spatial and temporal) to further reduce memory usage, configurable via the tiling parameters.
Use this node as the final step in a video generation pipeline to export the result to a common video container format.
Inputs
| Input | Type | Required | Default | Notes |
|---|---|---|---|---|
video_latent | LATENT | Yes | – | The latent representation of the video frames. Typically obtained from a compatible video diffusion model. |
audio_latent | LATENT | No | – | The latent representation of the audio frames. If provided, an audio_vae must also be connected. Leave disconnected for silent video output. |
fps | FLOAT | Yes | 25.0 | Frame rate of the output video. Range: 0 – 999 (step 0.01). |
filename_prefix | STRING | Yes | video/ComfyUI | Prefix for the saved video file. May include formatting tokens such as %date:yyyy-MM-dd% or node value references like %Empty Latent Image.width%. The node automatically appends a unique suffix to avoid overwrites. |
format | COMBO | Yes | auto | Output container format. Options depend on the available system encoders (e.g., mp4, avi, mkv, webm). auto selects the most widely‑supported format (typically MP4). |
codec | COMBO | Yes | auto | Video codec to use. Options depend on system‑installed encoders (e.g., libx264, libx265, libvpx, libaom-av1). auto picks a commonly available codec (usually H.264). |
video_vae | VAE | Yes | – | The VAE model used to decode the video_latent into pixel frames. Must be compatible with the latent representation. |
audio_vae | VAE | No | – | The VAE model used to decode the audio_latent into audio samples. Required when audio_latent is connected. |
tiling | DYNAMICCOMBO | Yes | – | Tiling mode for video decoding. Dynamic options may include disable (full frame decode), spatial (tile only spatially), temporal (tile only temporally), or both. The exact choices depend on the node implementation and the connected VAE. |
tile_size | INT | Yes | 512 | Width/height of each spatial tile. Smaller values reduce peak memory usage but increase decode time. Range: 64 – 4096 (step 32). Only used when spatial tiling is active. |
overlap | INT | Yes | 64 | Overlap (in pixels) between adjacent spatial tiles. Higher overlap reduces visible seams at tile boundaries, at the cost of more memory and processing time. Range: 0 – 4096 (step 32). |
temporal_size | INT | Yes | 4096 | Number of frames to decode at once when temporal tiling is enabled. A value larger than the total frame count effectively disables temporal tiling. Only relevant for video VAEs that support temporal tiling. Range: 8 – 4096 (step 4). |
temporal_overlap | INT | Yes | 16 | Number of overlapping frames between consecutive temporal chunks. Higher overlap can smooth out temporal seams, but uses more memory and increases decode time. Range: 4 – 4096 (step 4). |
Tiling behaviour
- When
tilingis disabled, the entire frame is decoded at once – this uses the most memory. - Spatial tiling (
tiling = "spatial"or"both") splits each frame into smaller tiles of sizetile_size×tile_size, decodes them independently, and blends overlapping regions. - Temporal tiling (
tiling = "temporal"or"both") splits the frame sequence into chunks oftemporal_sizeframes, each chunk overlapping bytemporal_overlapframes. Only applicable for VAEs that support temporal decomposition (e.g., some video VAEs). - The node automatically handles the blending of overlapping regions and tile borders.
Outputs
This node has no output connections. The decoded video is written directly to disk using the path constructed from filename_prefix. The node does not return any data to the workflow.
Usage Notes
- Memory management: The node streams decoded frames to disk as they are produced. Even with tiling disabled, it will not accumulate all frames in memory simultaneously. Tiling further reduces peak memory at the cost of slower decoding.
- Audio: To include audio, provide both an
audio_latentand anaudio_vae. The audio VAE must match the audio latent space (e.g., from an audio diffusion model). If no audio latent is connected, the output video will be silent. - Format and codec support: The available formats and codecs depend on the FFmpeg (or other encoder) installation on your system. Use
autofor a hassle‑free experience; if you need a specific codec or container, ensure the required encoder is installed. - Filename prefix tokens: You can use ComfyUI’s formatting syntax to include date, time, or node values. For example:
video/ComfyUI_%empty_latent_image.width%x%empty_latent_image.height%_%date:yyyy-MM-dd%
will produce filenames likevideo/ComfyUI_512x512_2025-01-15_0001.mp4. - Tile size tuning: For most use cases, a
tile_sizeof 512 andoverlapof 64 provide a good trade‑off between memory and speed. Increasetile_sizeif memory permits; decrease it if you run out of VRAM. - Temporal tiling: This is only effective with VAEs that natively support temporal tiling. If your VAE does not, setting temporal parameters will have no effect.
- Step increments: All integer tile parameters enforce the step size defined in the node (32 for spatial, 4 for temporal). Values not aligned to the step are automatically rounded.
Comments
Sign in with GitHub to join the discussion.