Description
The Encode Video Components node extracts frames from a video, resizes them to a specified resolution, and encodes them directly through a VAE into a latent representation. It processes frames one by one, avoiding the memory cost of storing the full image tensor for the entire video at once. The node also passes through the audio track from the input video and outputs metadata such as frame rate and total frame count.
Inputs
- video (
VIDEO, required) — The video file or sequence to process. Must be a valid video input as accepted by ComfyUI-KJNodes. - vae (
VAE, required) — The VAE model used for encoding the resized frames into latent space. - width (
INT, default:768, range:0–16384, step:2) — Target width for each frame before encoding. Set to0to keep the original video width. - height (
INT, default:512, range:0–16384, step:2) — Target height for each frame before encoding. Set to0to keep the original video height. - max_frames (
INT, default:0, range:0–999999, step:1) — Maximum number of frames to process.0means no limit and the entire video is processed. - upscale_method (
COMBO, default:"lanczos") — Interpolation algorithm used when resizing frames. Options:nearest-exact— Fast, nearest-neighbor interpolation; can produce blocky results.bilinear— Smooth, good for general scaling.area— Area-based resizing; effective when downscaling.bicubic— Higher quality than bilinear, slightly slower.lanczos— Sharp resampling, often preferred for high-quality downscaling.
- keep_proportion (
DYNAMICCOMBO, required) — Controls how to handle aspect ratio mismatch when the target width/height differ from the frame's original aspect ratio. This is a dynamic dropdown that adapts available options based on other inputs; common modes include"crop","pad","stretch", or"fit". See usage notes for details.
Outputs
- LATENT — The VAE-encoded latent representation of all processed frames, stacked as a batch. The shape matches the VAE's expected latent dimensions.
- AUDIO — The audio track extracted from the input video, if present. This output may be empty or
Noneif the video has no audio. - FLOAT — The frame rate (FPS) of the original video, as a floating-point number.
- INT — The total number of frames actually processed (respecting
max_frameslimit).
Usage Notes
- The node processes frames sequentially and feeds each resized frame to the VAE immediately, significantly reducing peak memory usage compared to loading an entire video into a batch of images first.
- Set
widthand/orheightto0to preserve the original dimension. If both are non-zero, they define the target resolution. Thekeep_proportionsetting determines how aspect ratio mismatches are resolved. - The
keep_proportioncombo is labeled "How to handle aspect ratio mismatch when resizing" in the tooltip. Its exact options depend on the node’s implementation (e.g.,"crop to fit","pad","ignore", or"fit"). Test the node in your workflow to see available choices. upscale_methodonly affects frames that are actually resized (i.e., when width or height differs from the original). If both dimensions match the original, no resizing occurs and this parameter is ignored.- Use
max_framesto limit processing for long videos or to debug with a subset of frames. Setting0(default) processes the entire video. - The output
LATENTcan be fed directly into sampling nodes (e.g., KSampler) that accept latent batches. The latent batch size equals the frame count. - If the input video has no audio track, the
AUDIOoutput will be an empty placeholder; downstream nodes expecting audio should handle this gracefully. - The
FLOAToutput (frame rate) andINToutput (frame count) can be useful for synchronizing subsequent steps that depend on timing or for reporting purposes.
Comments
Sign in with GitHub to join the discussion.