Trim audio by timestamp
A start at 30.5 seconds and an end at 95.25 seconds give a 64.75-second clip, checked against a 245.75-second recording. Reversed or out-of-range times are rejected, never quietly fixed. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Duration seconds
- 245.75
- Start seconds
- 30.5
- End seconds
- 95.25
- Clip duration seconds
- 64.75
Trim audio by timestamp calculations should be simple, predictable, and safe before a media workflow begins. Provide the total audio duration plus a start and end timestamp in seconds, and this tool validates that the requested range belongs to the recording before calculating the exact clip duration. It rejects an end time that comes before the start, any timestamp beyond the available audio, negative values, missing fields, and non-finite numbers. No audio is uploaded or changed: the result is a deterministic range calculation that can be used to prepare an editor command, validate a form, check chapter boundaries, or test a media pipeline before costly processing starts.
Define the trim range in seconds
A timestamp trim range has three independent facts: the total length of the source audio, the point where the selected clip begins, and the point where it ends. This calculator expresses all three in seconds so there is no hidden conversion between clock notation, samples, frames, or milliseconds. Decimal seconds are supported, which makes values such as 12.5 useful for speech edits and other cuts that do not land on a whole second.
The start timestamp is measured from the beginning of the recording, where zero means the first instant. The end timestamp is also measured from that same origin, rather than being interpreted as a requested length. Once the range is valid, clip duration is end minus start.
For example, a start at 30.5 seconds and an end at 95.25 seconds produce a 64.75-second clip. The total audio duration is not part of that subtraction; it supplies the upper boundary that proves both timestamps can exist in the source. A start equal to the end is accepted and returns a zero-second selection, which is useful when validating interactive handles before requiring a non-empty export elsewhere.
The maximum accepted duration is published in the input contract, and every accepted value must be finite and non-negative.
Understand each validation failure
Range validation happens before a duration is returned, because a plausible-looking subtraction can hide an impossible edit. Each required field must be present and must contain a finite non-negative number. Values such as negative seconds, Infinity, NaN, blank text, or descriptive clock strings are rejected instead of being guessed.
The end cannot be before the start, because that would describe a reversed interval and produce a negative clip duration. Finally, the end cannot exceed the total duration, even when the start itself is valid. An end exactly equal to the source duration is allowed and represents a clip that runs through the final instant of the audio.
If more than one condition is wrong, correct the reported issue and submit the range again; deterministic validation order ensures the same input reports the same first failure. Explicit correction is safer for editing interfaces and automated pipelines.
Use the result before processing audio
Keeping the normalized inputs beside the computed value makes the response easy to log, inspect, and compare with an editing request. A web form can call the calculation when either trim handle moves and show the selected length immediately. A backend can place the same check before an FFmpeg job, rejecting an impossible range without allocating media-processing capacity.
Test suites can use it to verify chapter markers, podcast excerpts, voice-note selections, transcription segments, or user-entered cue points. Because the algorithm performs only validation and subtraction, it does not inspect a file, confirm that a supplied duration matches real media, account for codec seek precision, snap to sample boundaries, or create an output clip. Those operations belong to an audio-processing capability after the range has been approved.
When integrating, preserve seconds as numbers for as long as possible and format them as minutes and seconds only for display; this avoids parsing ambiguity and keeps comparisons reliable.
What you can do with it
Validate an editor selection
Check drag-handle timestamps against the source duration and show the exact selected length before enabling export.
Guard an audio processing job
Reject reversed or out-of-bounds trim parameters before an FFmpeg worker downloads or decodes the source file.
Check podcast and transcript markers
Verify that excerpt or chapter boundaries fit inside a recording and calculate each segment's duration.
FAQ
Does this tool modify or upload my audio?
No. It only validates numeric timestamps and calculates a duration; it does not receive, inspect, or edit an audio file.
What units should I use?
Provide the total duration, start, and end as seconds. Decimal seconds are accepted for sub-second precision.
Can the end timestamp equal the total duration?
Yes. That represents a clip continuing through the end of the source audio.
What happens when the start and end are equal?
A later editing step may impose its own minimum clip length.
Why are reversed or out-of-range times rejected instead of fixed?
Because quietly clamping a time to the end of the file, swapping the start and end or dropping a minus sign can approve a cut you never meant. You get a clear rejection instead, so you can correct the actual mistake.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/audio/trim-by-timestamp \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"duration_seconds":245.75,"start_seconds":30.5,"end_seconds":95.25}'const res = await fetch("https://api.kit.forhosting.com/audio/trim-by-timestamp", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"duration_seconds": 245.75,
"start_seconds": 30.5,
"end_seconds": 95.25
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/audio/trim-by-timestamp",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"duration_seconds": 245.75,
"start_seconds": 30.5,
"end_seconds": 95.25
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/audio/trim-by-timestamp", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"duration_seconds":245.75,"start_seconds":30.5,"end_seconds":95.25}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"duration_seconds":245.75,"start_seconds":30.5,"end_seconds":95.25}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/audio/trim-by-timestamp", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"duration_seconds": 245.75,
"start_seconds": 30.5,
"end_seconds": 95.25
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "audio.trim_by_timestamp",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_duration_seconds | 3155760000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Understand each validation failure
The start cannot lie beyond the total duration: a five-minute recording has no valid starting point at six minutes. These rules are deliberately separate so an API client receives a useful invalid_input message naming the failed relationship. This tool does not silently clamp timestamps to the source boundary, swap reversed endpoints, or take an absolute value, because those conveniences can approve a cut the user never intended.
Use the result before processing audio
The successful response echoes the validated total duration, start timestamp, and end timestamp, then adds clip_duration_seconds. The browser version is available without charge, while an API request costs $0.002.
Technical questions
How much does an API calculation cost?
Each successful API request costs $0.002. The browser runner is free, and invalid requests are not charged.