ComfyUI Node

TS Video Cut

The trim node that keeps picture and sound in sync

By AlexYez·Created 2 years ago·Updated a day ago· 11
TS Video Cut
  • images
  • audio
  • images
  • audio
fps24.000
start_cut0
end_cut0

Trimming frames off the start and end of a clip sounds like a two-node job, and that's the problem. You slice the IMAGE batch with one node, slice the AUDIO with another, and tell them the same boundary in two different units - frames for the video, seconds or samples for the audio. The first fractional frame rate, 23.976 instead of 24, pulls the sound away from the picture, and suddenly your cut is off by half a second.

TS Video Cut does both from one pair of numbers given in frames. The frame boundary is the master, and the audio boundary is derived from it through fps, so the two cannot disagree. The author measured the drift after cutting: 0.00 ms at 24 fps, 0.01 ms on a 23.976 clip, 0.00 ms even when the audio arrived three frames longer than the video. That last one is the quiet win - encoders round differently, so a soundtrack that's slightly longer or shorter than the picture is routine. The cut span is clamped to the audio that actually exists, and a mismatch over 50 ms gets a line in the log so you know the two aren't quite the same length.

Mechanically it's simple: the batch is sliced [start_cut : total - end_cut] and the audio cut to the same span via fps. Leave the audio socket unconnected and you still get audio out - silence of exactly the trimmed length - so a downstream saver receives a valid track instead of nothing. And cutting away the whole clip is refused with the numbers in the message rather than handing an empty batch to whatever comes next.

The inputs, all four

images is the frame batch, treated as a clip in playback order. fps is what turns a cut in frames into a cut in samples, so it must match the real rate - 23.976 or 29.97 written out in full, not rounded to 24 or 30. start_cut and end_cut are how many frames to remove from each end. Optional audio plugs in the soundtrack. Outputs are the trimmed images and the matching audio, and both go straight into a saver or preview node.

Install

Install is the whole pack: ComfyUI Manager → search "Timesaver", or cd ComfyUI/custom_nodes && git clone https://github.com/AlexYez/comfyui-timesaver, then restart. No extra dependencies for this one - it's pure torch on the image side and imageio-ffmpeg (which ships with the pack) on the audio side, so no system ffmpeg install either.

Common issues

Where people get burned: entering an fps that doesn't match the real rate - the tooltip isn't being fussy, 23.976 vs 24 is six minutes of drift per hour of video - and trimming more frames than the clip has, which the node refuses rather than guessing. Set the numbers right and it's the most boring node in your graph, which is exactly what you want from a trim.

CategoryTS/Video

Inputs (5)

NameTypeDefaultDescription
imagesIMAGEFrames to trim. The batch is treated as a clip in playback order.
fpsFLOAT24.0000.01–1000Frame rate the clip plays at. This is what turns a cut in frames into a cut in samples, so it must match the real rate — 23.976 or 29.97 are written out in full, not rounded to 24 or 30.
start_cutINT00–1000000How many frames to remove from the START of the clip.
end_cutINT00–1000000How many frames to remove from the END of the clip.
audiooptAUDIOSoundtrack to cut alongside the frames. Optional: with nothing connected the node outputs silence of exactly the trimmed length, so a downstream saver still gets a valid audio track.

Outputs (2)

NameTypeDescription
imagesIMAGEThe trimmed frames.
audioAUDIOAudio cut to the same span.