MD: Latent Time Mask (Timeline Director)
Direct a latent like a timeline — mask an intro, regen just the chorus
- latent
- time_mask
- mask_plot
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 -
Autoguesses, 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.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| latent | LATENT | LATENT INPUT • Purpose: The target latent to mask. • Action: Used to determine total duration and batch dimensions. | |
| latent_format | COMBO | Auto | FORMAT 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. |
| fps | FLOAT | 24.001–120 | FRAME RATE • Purpose: Used to calculate accurate seconds. ⭐ Note: For Ace-Step audio, usually ~21.5 or check model spec. |
| start_seconds | FLOAT | 0.00–3600 | START TIME • Purpose: When the mask becomes 100% active. |
| end_seconds | FLOAT | 10.00–3600 | END TIME • Purpose: When the mask stops being active. |
| fade_in | FLOAT | 1.00–60 | FADE IN • Purpose: Soft transition duration at start. |
| fade_out | FLOAT | 1.00–60 | FADE OUT • Purpose: Soft transition duration at end. |
| invert | BOOLEAN | false | INVERT • Purpose: Flips the mask (Active becomes Inactive). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| time_mask | MASK | — |
| mask_plot | IMAGE | — |