Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > ComfyUI-H3-Project-Suite > H3 Context Trim

ComfyUI Node: H3 Context Trim

Class Name

H3ContextTrim

Category
conditioning/minimax
Author
Adudeguyman (Account age: 1120days)
Extension
ComfyUI-H3-Project-Suite
Latest Updated
2026-11-13
Github Stars
0.05K

How to Install ComfyUI-H3-Project-Suite

Install this extension via the ComfyUI Manager by searching for ComfyUI-H3-Project-Suite
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-H3-Project-Suite in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

H3 Context Trim Description

Trims leading H3 video context frames and synchronizes matching audio to the remaining clip.

H3 Context Trim:

H3ContextTrim removes leading pinned frames from a decoded H3 video clip while keeping the picture and sound synchronized. It is designed for workflows where an H3-generated clip contains context frames at the beginning that should not appear in the final result. When sound is connected, the node removes the matching amount of audio based on the clip frame rate, preventing the soundtrack from starting earlier than the remaining video. It can also adjust the end of the audio so its duration matches the remaining picture exactly, which helps prevent small timing errors from accumulating when multiple clips are joined together. Silent clips can be processed with only the image stream connected.

H3 Context Trim Input Parameters:

images

The decoded video frames to process, provided as an IMAGE sequence. The node counts the frames in this sequence, removes the number specified by trim_frames from the beginning, and returns the remaining frames in the same order. This input must contain more frames than the requested trim amount; attempting to remove all frames or more than all available frames produces an error. The image sequence is also used to determine how much audio should remain when audio is connected.

trim_frames

The number of leading video frames to remove, provided as an INT. The default value is 0, the minimum is 0, and the maximum is 4096. A value of 0 leaves the image sequence unchanged, while a value such as 5 removes the first five frames. When audio is connected, the node converts this frame count into a time duration using fps and removes the equivalent number of audio samples. Connect the frame count produced by the H3 motion or context workflow when possible, because this keeps the trim amount consistent with the frames actually generated by the encoder. The value cannot be equal to or greater than the total number of input frames.

audio

Optional decoded audio for the same clip, provided as an AUDIO value. When connected, the node removes the audio portion corresponding to trim_frames so the soundtrack remains aligned with the trimmed images. The audio must contain a waveform and sample rate, and it should belong to the same clip as images. When audio is left unwired, only the image frames are trimmed; this is suitable for silent clips, but any separate soundtrack will still include the removed leading duration and may play ahead of the picture. The node preserves the audio sample rate and can trim or pad the waveform tail when match_tail is enabled.

fps

The frame rate used to convert video frames into an audio duration, provided as a FLOAT. The default is 24.0, the minimum is 1.0, and the maximum is 240.0; the control accepts increments of 0.001. This value must match the frame rate used when the clip is created or passed to the video-making stage. For example, at 24 frames per second, trimming 5 frames removes approximately 0.2083 seconds of audio. An incorrect frame rate causes the node to remove too much or too little sound, which can create audio drift or synchronization problems.

match_tail

Controls whether the remaining audio is adjusted to have the exact duration of the remaining image sequence, provided as a BOOLEAN. The default is True. When enabled, the node calculates the desired duration from the number of remaining frames and fps; it truncates extra audio samples or adds silent zero samples when the waveform is slightly too short. This compensates for rounding differences between H3's audio timing and the video frame timing, helping prevent timing drift across concatenated clips. Set it to False when you need to preserve the audio waveform exactly after the leading trim, accepting that a small duration difference may remain.

H3 Context Trim Output Parameters:

images

The trimmed video frame sequence, provided as an IMAGE value. It contains all input frames after the first trim_frames frames have been removed. The remaining frames retain their original order and image data. If trim_frames is 0, this output is the same image sequence as the input. Use this output for later video creation, compositing, or concatenation steps.

audio

The trimmed audio value, provided as an AUDIO value. If an audio input was connected, its waveform has had the matching leading duration removed, and its tail may have been truncated or padded depending on match_tail. The output keeps the original audio sample rate. If no audio was connected, this output remains empty or None, allowing the node to be used for silent clips without creating artificial audio.

H3 Context Trim Usage Tips:

  • Connect the same decoded clip to both images and audio whenever the clip contains sound. Trimming only the images leaves the soundtrack longer at the beginning and can make the audio play ahead of the video.
  • Set trim_frames to the exact number of H3 context or pinned frames that should be removed. A value of 0 performs no leading trim, while a value equal to or greater than the image count is invalid.
  • Keep fps equal to the frame rate used by the downstream video creation node. The default 24.0 is appropriate for 24 fps material; change it for clips created at another frame rate.
  • Leave match_tail enabled for clips that will be concatenated with other clips. It corrects small end-of-clip timing differences and prevents drift from accumulating at later joins.
  • Set match_tail to False only when preserving the exact post-trim waveform is more important than making the audio duration match the remaining picture.
  • For silent clips, leave audio unwired. The node will still remove the requested image frames without requiring an audio stream.
  • Check that the connected audio belongs to the same clip and begins at the same time as the connected images. Using unrelated audio can produce a technically aligned but creatively incorrect result.
  • Use the node before concatenating H3 clips or passing the result to a video muxing step. This ensures that the pinned context frames and their corresponding sound are removed before the clips are joined.

H3 Context Trim Common Errors and Solutions:

h3_suite: asked to trim %d frames from a %d frame clip

  • Explanation: The requested trim_frames value is equal to or greater than the total number of frames in images. Removing that many frames would leave no video frames to return.
  • Solution: Lower trim_frames so it is smaller than the image sequence length. Check that the correct clip is connected and that the frame count was not accidentally interpreted as a duration or sample count.

h3_suite: trimming %.3fs from %.3fs of audio would leave nothing. Check that fps matches the clip.

  • Explanation: The requested leading trim represents a duration equal to or longer than the connected audio duration. This commonly happens when trim_frames is too large, the audio does not belong to the same clip, or fps is lower than the actual video frame rate.
  • Solution: Reduce trim_frames, connect the matching audio, or set fps to the actual frame rate used to create the video. Confirm that the audio contains enough samples for the requested trim.

Audio and video remain out of sync after trimming

  • Explanation: The fps value may not match the clip's real frame rate, or the connected audio and image streams may come from different clips. The node uses fps to calculate how much sound corresponds to the removed frames.
  • Solution: Set fps to the exact frame rate used by the video workflow, commonly 24.0 for 24 fps material. Verify that both inputs represent the same clip and that the audio starts at the same point as the images.

Audio is longer or shorter than the remaining video

  • Explanation: Small duration differences can occur because the audio and video timelines use different timing grids and require rounding to whole audio samples. Larger differences usually indicate an incorrect fps value or mismatched media inputs.
  • Solution: Keep match_tail enabled so the node truncates excess samples or pads missing samples with silence. If the difference is large, verify the frame rate and replace the audio with the soundtrack belonging to the image sequence.

Audio is missing from the output

  • Explanation: The audio input was not connected, so the node returned the trimmed images without an audio value. This is expected for silent clips but means that an external soundtrack will not be trimmed automatically.
  • Solution: Connect the decoded audio for the same clip to audio before this node. If the clip is intentionally silent, no correction is needed.

Audio contains an unexpected silent extension at the end

  • Explanation: match_tail is enabled and the remaining waveform is shorter than the duration calculated from the remaining frame count and fps. The node adds zero-value samples, which are silence, to match the target duration.
  • Solution: Confirm that fps is correct and that the audio belongs to the same clip. Set match_tail to False if preserving the original waveform length is required, understanding that the audio and picture may then differ slightly in duration.

Audio ending is cut earlier than expected

  • Explanation: match_tail is enabled and the remaining waveform is longer than the calculated video duration. The node removes the excess samples from the end so the sound ends with the remaining picture.
  • Solution: Verify the fps setting and the total image count. Disable match_tail only when retaining the extra audio is intentional; otherwise, the truncation prevents timing drift when clips are joined.

H3 Context Trim Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-H3-Project-Suite
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

H3 Context Trim