ComfyUI > Nodes > ComfyUI > Trim Audio Duration

ComfyUI Node: Trim Audio Duration

Class Name

TrimAudioDuration

Category
audio
Author
ComfyAnonymous (Account age: 763days)
Extension
ComfyUI
Latest Updated
2026-05-13
Github Stars
112.77K

How to Install ComfyUI

Install this extension via the ComfyUI Manager by searching for ComfyUI
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI 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

Trim Audio Duration Description

Precisely trims audio waveform to specified time range for segment extraction, maintaining quality and integrity.

Trim Audio Duration:

The TrimAudioDuration node is designed to precisely trim an audio waveform to a specified time range, allowing you to extract a particular segment from a longer audio file. This node is particularly useful when you need to focus on a specific part of an audio track, whether for artistic purposes, analysis, or processing. By specifying a start time and duration, you can easily isolate the desired section of audio, making it a versatile tool for audio editing and manipulation. The node ensures that the trimming process respects the audio's sample rate, maintaining the integrity and quality of the extracted segment. This functionality is essential for tasks that require precise audio editing, such as creating loops, samples, or sound effects.

Trim Audio Duration Input Parameters:

audio

This parameter represents the audio data that you want to trim. It is expected to be a dictionary containing the waveform and sample rate of the audio. The waveform is the actual audio signal, while the sample rate indicates how many samples per second are in the audio. The audio parameter is crucial as it provides the raw material that the node will process.

start_index

The start_index parameter specifies the starting point of the audio segment you wish to extract, measured in seconds. It can be a positive value, indicating the start time from the beginning of the audio, or a negative value, which allows you to count backward from the end of the audio. This flexibility is useful for quickly accessing the end of an audio file without needing to calculate its total length. The default value is 0.0 seconds, with no explicit minimum or maximum, but it should logically fall within the audio's duration.

duration

This parameter defines the length of the audio segment to be extracted, measured in seconds. It determines how much of the audio will be included in the output starting from the start_index. The duration must be a positive value, with a default of 60.0 seconds. This parameter is essential for controlling the size of the trimmed audio segment, allowing you to extract precisely the amount of audio you need.

Trim Audio Duration Output Parameters:

waveform

The waveform output is the trimmed audio signal, represented as a tensor. This is the actual audio data that has been extracted based on the specified start_index and duration. It is crucial for further processing or playback, as it contains the audio segment you intended to isolate.

sample_rate

The sample_rate output is the sample rate of the trimmed audio, which remains unchanged from the input audio. It is important because it ensures that the playback speed and quality of the audio segment are consistent with the original audio file.

Trim Audio Duration Usage Tips:

  • To extract a segment from the end of an audio file, use a negative start_index value. This allows you to specify the start time relative to the end of the audio, which can be convenient for quickly accessing the final parts of a track.
  • Ensure that the duration parameter does not exceed the remaining length of the audio from the start_index. If the specified duration is too long, it will be automatically adjusted to fit within the available audio length.

Trim Audio Duration Common Errors and Solutions:

Trim Audio Duration: Start time must be less than end time and be within the audio length.

  • Explanation: This error occurs when the calculated end time of the audio segment is less than or equal to the start time, or if the start time is outside the bounds of the audio length.
  • Solution: Ensure that the start_index and duration parameters are set such that the end time is greater than the start time and both are within the audio's total duration. Adjust the start_index or duration to fit within the audio's length.

Trim Audio Duration Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI
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.

Trim Audio Duration