H3 Motion Context Trim
The trim node that keeps your chained H3 soundtrack on the beat
- images
- audio
- images
- audio
If you're chaining H3 clips with the Motion Context node, you've seen this node's job already: the pinned frames come back at the start of the delivered clip, and they have to come off before you concatenate. This is the node that takes them off. The reason it exists as a separate thing rather than just an image crop is the sound - trim the images only and your audio is left trim_frames/24 seconds longer than the picture. At 5 frames that's 208 ms, silent on ambience but squarely offbeat on anything with a pulse.
So it removes the same span from both streams: whole frames off the images, the matching number of samples off the waveform. Picture and sound stay locked, which is the whole point of chaining H3, since H3 generates them together.
There's a second, sneakier job here. H3's audio latent runs at 40 Hz against 24 fps picture, and the grid rarely lands on a frame boundary - the model rounds to the nearest audio step, so every clip ships either about 8 ms too much sound or about 8 ms too little, depending on its length. A single clip, nobody notices. Concatenate a chain and the error stacks: 16.7 ms at the second seam, 25 ms at the third, growing without bound. It reads as a faint dampening at the first join and a short click at later ones. The match_tail setting fixes exactly that by making the audio duration equal frames/fps, truncating a long tail or padding a short one with silence. Leave it on - the node has no way of knowing what the Motion Context node did, so it stays a setting, but every "it works" in the pack's README assumes it.
Inputs and outputs
The two inputs that matter:
images- the decoded clip from your VAE decode.trim_frames- wire this from the Motion Context node'strim_framesoutput. Don't type it in. The pinned span is whatever the encoder actually produced, and the Motion Context node reports that number to you; typing a guess into two widgets is how you get a seam.
Optionally wire audio (decoded sound for the same clip; skip it for silent clips) and set fps to match what you feed Create Video - it converts the frame trim into an audio duration. Outputs are images and audio, both trimmed by the same span, ready to feed Create Video or a Save Audio node.
Install
Same as the rest of the pack - ComfyUI Manager (search "H3 Motion Context") or:
cd ComfyUI/custom_nodes
git clone https://github.com/NikoDemon80/ComfyUI-H3-Motion-Context
then restart. No model downloads, no extra dependencies; the H3 model and its video/audio VAEs are the things you already had.
Common issues
The one real error is asking it to trim more frames than the clip has - the node refuses rather than handing back a negative-length clip, which usually means your fps doesn't match the clip's real rate. If you're scripting the output afterward, remember H3 emits 32 kHz audio, not 48; a stream-copy concat can't change rate partway, so a hardcoded 48000 silently turns the tail of a long episode into nothing while every duration check still passes. Read the rate off the clip before you mux. There's also a logged note if you trim without wiring audio: the node tells you your soundtrack is about to run ahead of the picture, which is the polite version of the failure this node exists to prevent.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| trim_frames | INT | 00–4096 | — |
| audioopt | AUDIO | Decoded audio for the same clip. Trimmed by the matching duration so sound stays locked to picture. Leave unwired for silent clips. | |
| fpsopt | FLOAT | 24.0001–240 | Frame rate used to convert the trim into an audio duration. Must match what you feed Create Video. |
| match_tailopt | BOOLEAN | true | Make the audio duration equal frames/fps exactly, trimming a long tail or padding a short one with silence. H3 rounds its audio grid to the nearest step, so each clip carries about 8ms too much or too little sound, which accumulates at every join in a chain. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| audio | AUDIO | — |