Kandinsky S2V Trim To Audio:
KandinskyS2VTrimToAudio removes the extra video frames generated beyond the original audio track’s duration in a Kandinsky S2V workflow. Because speech-driven video is generated in chunks, the final chunk can include frames corresponding to silence added to complete that chunk. This node trims that padded tail by calculating how many frames fit within the original track’s duration at the model’s fixed rate of 25 frames per second, rounding down to a whole frame. It preserves the beginning of the sequence and the original frame order without changing the retained pictures. This helps you prepare a clip whose length follows the audio rather than the padded generation length. It does not detect silence within a recording, remove pauses, generate missing frames, or stretch a shorter video to match a longer track.
Kandinsky S2V Trim To Audio Input Parameters:
images
Required input of type IMAGE. This is the decoded sequence of video frames you want to trim, normally supplied by VAE Decode after Kandinsky S2V Sampler. The node treats the first dimension of this image batch as the frame count and keeps only the initial frames needed for the original audio duration. Any excess frames are removed from the end; the retained frames keep their original appearance, dimensions, and order. If the sequence already contains fewer frames than the duration requires, all available frames are returned without adding new ones. No default value, numerical minimum, numerical maximum, or selectable options are defined in the node interface; you must connect an image sequence.
conditioning
Required input of type KANDINSKY_S2V_CONDITIONING. Connect the conditioning produced by Kandinsky S2V Encode (speech + prompt), ideally the same conditioning used to generate the video. The node reads its track_seconds value, which represents the original audio track’s duration in seconds, and multiplies that duration by 25 to determine the target frame count. The result is rounded down to a whole number and limited to the number of frames available. Although the conditioning also supports other parts of the Kandinsky S2V workflow, this node uses only the track duration; it does not inspect the speech content or prompt. No default value, numerical minimum, numerical maximum, or selectable options are defined for this connection.
Kandinsky S2V Trim To Audio Output Parameters:
images
Output of type IMAGE containing the retained video frames in their original order. The frame count is the smaller of the available frame count and the original audio duration multiplied by 25, rounded down to a whole number. For example, a 10.5-second track allows 262 frames, so a longer sequence is reduced to its first 262 frames. At 25 frames per second, this corresponds to 10.48 seconds: rounding can make the video slightly shorter than the audio by less than one frame interval when sufficient frames are available. This output contains images only, not an encoded video or an audio track, and can be connected to a video-creation node.
fps
Output of type FLOAT with the fixed value 25.0. This is the playback frame rate used to calculate the trim length and is the rate you should use when assembling the returned images into a video. Connecting it to the frame-rate input of your video-creation node keeps playback timing consistent with the duration calculation. It is not measured from the image sequence, does not vary with audio length, and does not perform frame-rate conversion or interpolation.
Kandinsky S2V Trim To Audio Usage Tips:
- Place this node after VAE Decode: connect Kandinsky S2V Sampler to VAE Decode, then connect the decoded images to
images. The trim node expects image frames, not the sampler’s latent output. - Connect the same
conditioningused by Kandinsky S2V Sampler. This ensures that trimming uses the duration of the audio associated with your generated clip rather than a different recording. - Connect both returned
imagesandfpsto the corresponding inputs of CreateVideo or a compatible video-assembly node, and supply the original audio separately. The trim node does not attach audio itself. - Keep the video-assembly frame rate at
25.0. Changing playback speed downstream changes the clip’s duration and can cause the video and audio to drift apart. - Generate enough chunks upstream to cover your recording. This node can remove extra frames but cannot repair a video that ends before the audio; if necessary, use the encoder’s automatic chunk selection by setting its
chunksparameter to0. - Do not expect pauses or silence already present in your original recording to be removed. Trimming is based on the full recorded duration, not on detecting when someone is speaking.
- There are no adjustable trim or frame-rate controls on this node. For a custom endpoint or a different playback rate, use separate editing tools and account for their effect on audio synchronization.
Kandinsky S2V Trim To Audio Common Errors and Solutions:
'track_seconds'
- Explanation: A Python
KeyErrorwith this text means the conditioning data does not contain the audio-duration entry required for trimming. The node accesses this entry directly and does not provide a fallback. - Solution: Connect conditioning directly from Kandinsky S2V Encode (speech + prompt), preferably the same output connected to your sampler. Avoid substituting ordinary text conditioning or manually constructed data that lacks the track duration.
Input type mismatch for images or conditioning
- Explanation: ComfyUI may report a connection or validation error if
imagesreceives latent data rather thanIMAGEdata, or ifconditioningreceives a different conditioning type. The exact message depends on your ComfyUI version. - Solution: Decode the sampler’s output with VAE Decode before connecting it to
images, and useKANDINSKY_S2V_CONDITIONINGfrom Kandinsky S2V Encode forconditioning.
Required input is missing
- Explanation: Both
imagesandconditioningare required connections. ComfyUI cannot execute this node when either is missing; the exact validation message may vary. - Solution: Check that VAE Decode is connected to
imagesand Kandinsky S2V Encode is connected toconditioning. Make sure the upstream nodes also have all their required connections.
Invalid track duration: TypeError or ValueError
- Explanation: The node multiplies
track_secondsby the frame rate and converts the result to an integer. Malformed custom conditioning can cause aTypeErroror a conversion error such ascannot convert float NaN to integer; an infinite duration can producecannot convert float infinity to integer. - Solution: Regenerate conditioning through Kandinsky S2V Encode using a valid, nonempty audio track. If you modify conditioning through custom code, make sure
track_secondsis a finite, positive duration in seconds.
The returned clip is shorter than the audio
- Explanation: This can happen without an error message. Rounding down to whole frames normally leaves a difference of less than 0.04 seconds when enough frames are available. A larger difference can mean that too few frames were generated or that the wrong conditioning was connected.
- Solution: For a very small difference, no correction is usually necessary. For a substantial shortfall, verify the conditioning connection and generate enough chunks upstream; this node cannot extend the sequence.
The returned sequence is empty
- Explanation: This can happen without an error message if the incoming sequence has no frames or if the recorded duration rounds down to zero frames at 25 fps, as a positive duration shorter than 0.04 seconds would. The normal encoder rejects empty speech tracks, but custom conditioning can bypass that protection.
- Solution: Confirm that VAE Decode produced frames and that the audio is long enough to contain at least one frame interval. Recreate conditioning from the intended recording instead of using a zero or manually altered duration.
The video plays too fast, too slowly, or out of sync
- Explanation: This is usually a downstream playback-setting issue rather than a trim-node exception. The trim calculation assumes 25 fps, so assembling the same frames at another rate changes the playback duration.
- Solution: Connect the node’s
fpsoutput to your video-creation node, verify that the effective rate is25.0, and use the same original audio track that produced the conditioning.
