Nodes/MD Nodes/MD: Latent Time Mask (Timeline Director)
ComfyUI Node

MD: Latent Time Mask (Timeline Director)

Direct a latent like a timeline — mask an intro, regen just the chorus

By MDMAchine·Created about a year ago·Updated 3 months ago· 15
MD: Latent Time Mask (Timeline Director)
  • latent
  • time_mask
  • mask_plot
latent_formatAuto
fps24.00
start_seconds0.0
end_seconds10.0
fade_in1.0
fade_out1.0
invertfalse

MD_Latent_Time_Mask is a temporal mask generator for latents that have a time axis - video latents (AnimateDiff-style 5D tensors) or audio latents (ACE-Step-style 4D tensors). You tell it "seconds 0 to 10, with a 1-second fade at each end," and it hands you a MASK shaped to match your latent's time dimension, ready to feed into conditioning or a denoise workflow.

This is the kind of node you reach for when you want to regenerate part of a clip without touching the rest: keep the intro, re-roll the section from 0:15 to 0:30, and have the transition be a soft fade instead of a hard cut. The "Timeline Director" display name is fair - it's basically a time-range selector with fades, which is all you need to do surgical re-generation.

How it works

The node reads your latent's shape to figure out total frames, converts your seconds to frame indices using fps, then builds a 0→1 curve: zeros outside the range, ones inside, with linear ramps for fade-in and fade-out. It reshapes that curve to broadcast against your latent's time axis and, for 5D batched latents, expands it across the batch. The smart bit is overlap handling - if your fade lengths add up to more than the segment itself, it scales the fades down to fit rather than producing a broken mask. An annotated mask_plot image (matplotlib) shows you start/end markers and fade zones, which saves a lot of guesswork.

The inputs that matter

  • latent - the target latent; its shape sets total duration and dimensions.
  • latent_format - Auto guesses, but the dropdown exists because "which axis is time" is ambiguous: AnimateDiff (5D) is (batch, time, c, h, w), Ace-Step (4D) is (time, c, h, w). If Auto picks wrong, set it explicitly.
  • fps - converts seconds to frames. Default 24. For ACE-Step audio, the tooltip's reminder to check the model spec is real - it's usually around 21.5 frames per second, not a video frame rate.
  • start_seconds / end_seconds - the active window.
  • fade_in / fade_out - soft transition durations, in seconds.
  • invert - flips the mask, so the segment becomes the excluded region.

Outputs: the time_mask (MASK) to wire into conditioning or an inpainting-style patch, and mask_plot (IMAGE) for a visual sanity check.

Installing

Part of MD Nodes; install the pack once:

cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes
pip install -r requirements.txt

Or via ComfyUI Manager, search MD Nodes, restart. The mask_plot output needs matplotlib (it's in the requirements); the mask itself is pure torch and works without it.

Common issues

The trap is assuming seconds map 1:1 to frames everywhere. For video, 24 fps is fine; for ACE-Step audio, treating it like video fps will make your mask cover the wrong segment entirely - set fps to the model's actual rate. Also, masks only help if whatever consumes them respects time: check that your conditioning node or sampler actually supports a temporal mask before building a whole workflow around it. And if you set start_seconds past the clip length, you get an all-zero mask - the node clamps silently, so glance at the plot output rather than assuming.

CategoryMD_Nodes/Masking

Inputs (8)

NameTypeDefaultDescription
latentLATENTLATENT INPUT • Purpose: The target latent to mask. • Action: Used to determine total duration and batch dimensions.
latent_formatCOMBOAutoFORMAT HINT • Purpose: Helps the node identify which dimension is Time. • Options: 5D (Batch, Time, C, H, W) or 4D (Time, C, H, W). ⭐ Recommended: Auto usually guesses correctly.
fpsFLOAT24.001–120FRAME RATE • Purpose: Used to calculate accurate seconds. ⭐ Note: For Ace-Step audio, usually ~21.5 or check model spec.
start_secondsFLOAT0.00–3600START TIME • Purpose: When the mask becomes 100% active.
end_secondsFLOAT10.00–3600END TIME • Purpose: When the mask stops being active.
fade_inFLOAT1.00–60FADE IN • Purpose: Soft transition duration at start.
fade_outFLOAT1.00–60FADE OUT • Purpose: Soft transition duration at end.
invertBOOLEANfalseINVERT • Purpose: Flips the mask (Active becomes Inactive).

Outputs (2)

NameTypeDescription
time_maskMASK
mask_plotIMAGE