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
imagesandaudiowhenever 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_framesto the exact number of H3 context or pinned frames that should be removed. A value of0performs no leading trim, while a value equal to or greater than the image count is invalid. - Keep
fpsequal to the frame rate used by the downstream video creation node. The default24.0is appropriate for 24 fps material; change it for clips created at another frame rate. - Leave
match_tailenabled 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_tailtoFalseonly when preserving the exact post-trim waveform is more important than making the audio duration match the remaining picture. - For silent clips, leave
audiounwired. 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_framesvalue is equal to or greater than the total number of frames inimages. Removing that many frames would leave no video frames to return. - Solution: Lower
trim_framesso 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_framesis too large, the audio does not belong to the same clip, orfpsis lower than the actual video frame rate. - Solution: Reduce
trim_frames, connect the matching audio, or setfpsto 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
fpsvalue may not match the clip's real frame rate, or the connected audio and image streams may come from different clips. The node usesfpsto calculate how much sound corresponds to the removed frames. - Solution: Set
fpsto the exact frame rate used by the video workflow, commonly24.0for 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
fpsvalue or mismatched media inputs. - Solution: Keep
match_tailenabled 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
audioinput 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
audiobefore this node. If the clip is intentionally silent, no correction is needed.
Audio contains an unexpected silent extension at the end
- Explanation:
match_tailis enabled and the remaining waveform is shorter than the duration calculated from the remaining frame count andfps. The node adds zero-value samples, which are silence, to match the target duration. - Solution: Confirm that
fpsis correct and that the audio belongs to the same clip. Setmatch_tailtoFalseif 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_tailis 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
fpssetting and the total image count. Disablematch_tailonly when retaining the extra audio is intentional; otherwise, the truncation prevents timing drift when clips are joined.
