Nodes/S42 CutFlow/🔊 S42 CutFlow Audio Trim
ComfyUI Node

🔊 S42 CutFlow Audio Trim

Trim audio to exactly match your video — by frames, by seconds, or by vibe

By GeekyGhost·Created 6 months ago·Updated 4 months ago· 3
🔊 S42 CutFlow Audio Trim
  • audio
  • audio
  • info
modematch_frames
in_seconds0.0
out_seconds-1.0
fps24.0
target_frames48
fade_in0.0
fade_out0.0

The most tedious part of editing audio and video together is keeping their lengths in sync, and S42CF Audio Trim exists to make one half of that chore a single node. Give it an AUDIO input and it trims (or extends) it to the length you specify, with optional fades, in three different measurement systems. It sits in the Audio Sync category alongside Beat Snap and Audio-Video Sync, and it's the one you reach for when the video is already the right length and the audio needs to catch up.

The mode selector is the whole personality of this node:

  • match_frames (default) - trims the audio to target_frames at fps. This is the mode you wire into the rest of your graph: connect target_frames to a frame_count output from a video node (like S42CF Clip Info or Smart Trim) and the audio always comes out the same length as the video, whatever you change upstream. It pads with silence if the audio is too short, cuts if it's too long.
  • custom_time - trim by in_seconds / out_seconds. -1 for out means "to the end of the audio." The mode for "give me the middle 30 seconds."
  • custom_frames - trim by frame numbers at the given fps. For when your trim points live in a frame timeline and you don't want to do the seconds math by hand.

The other knobs: fps (for all frame-based math), fade_in and fade_out (in seconds, 0–10) - short fades here are the fix for the click you get when audio is cut mid-sample. Default 0 means a hard cut; even a 0.1s fade-out on a music loop is worth it.

The mechanism is transparent and safe: it converts everything to sample indices, clamps so you can't request a start past the end, slices, applies linear fades, and hands back a standard AUDIO plus an info string summarizing what it did. Pure numpy, no model, instant.

Where people get burned: assuming match_frames also matches the tempo or the content. It makes the length right - it can't make a 2-minute song fit a 30-second clip with the interesting part preserved. For that you want S42CF_AudioVideoSync's time_stretch, which squashes the whole thing. This node is for cutting to fit; that node is for stretching to fit. Different tools, same category, and knowing which one you want saves a lot of head-scratching.

Installing it

S42-CutFlow install: ComfyUI Manager → search "S42 CutFlow" → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/GeekyGhost/S42-CutFlow.git
pip install -r S42-CutFlow/requirements.txt

One-line requirements (opencv-python-headless); numpy does the slicing. "[S42 CutFlow] Loaded ..." on restart confirms the pack.

The takeaway

Wire target_frames to a video node's frame_count and you never manually calculate a trim again. Just don't expect it to rearrange the song - that's the stretch node's job.

CategoryS42 CutFlow/Audio Sync

Inputs (8)

NameTypeDefaultDescription
audioAUDIOComfyUI AUDIO input to trim.
modeCOMBOmatch_frames'match_frames' = trim audio to match connected clip frame count. 'custom_time' = trim to in/out seconds. 'custom_frames' = trim to in/out frame numbers at given fps.
in_secondsFLOAT0.00–99999Start time in seconds (custom_time mode).
out_secondsFLOAT-1.0-1–99999End time in seconds. -1 = end of audio.
fpsFLOAT24.01–120FPS for frame-based calculations.
target_framesINT481–99999Target frame count for match_frames mode.
fade_inFLOAT0.00–10Fade-in duration in seconds.
fade_outFLOAT0.00–10Fade-out duration in seconds.

Outputs (2)

NameTypeDescription
audioAUDIO
infoSTRING