Trim end 184 on a 172-second source: it clamps and warns, no error

Video trim clamps an end past the source length and returns warning trim_clamped_to_source. A 4 to 184 cut of a 172.4 s clip yields 168.4 s for $0.02.

5 min readSume
All posts

Send video trim a start of 4 and an end of 184 for a source that is 172.4 seconds long and the job does not fail. The end clamps to the source, the output is 172.4 - 4 = 168.4 seconds, and the result carries the warning trim_clamped_to_source. The job costs $0.02 either way.

This matters for Shorts: YouTube's page (read 2026-10-09) allows up to three minutes, so you might script a 180-second cut for every source without knowing each file's exact length. The clamp means a script that asks for 180 seconds gets the whole of any shorter file, and the warning tells you it happened.

What the doc says

The trim doc defines end as an out-point in seconds. If the value is after the end of the source, it clamps and the result gives the warning. Send only one of end or duration; sending both returns video_trim_range_conflict. Sending neither returns video_trim_range_required, and an end at or before the start returns video_trim_range_empty. The source must be 1,800 seconds or less and the output 900 seconds or less.

Trim outcomes for a 172.4 s source, behavior from the video trim doc (read 2026-10-08)
RequestResultWarning
start 4, end 184168.4 strim_clamped_to_source
start 0, end 172.4172.4 snone
start 4, end 4refusedvideo_trim_range_empty
start 4, end 184, duration 60refusedvideo_trim_range_conflict
start 4 onlyrefusedvideo_trim_range_required

Reading the result

The job result is kind video_trim with video_url (a new artf_), duration_seconds, actual_start_seconds, precision, audio, output and warnings[]. Do not trust the length you asked for; read duration_seconds. For exact precision the actual start equals your start. For keyframe precision, which is a stream copy, the cut can start a GOP early, so actual_start_seconds can be smaller than the start you sent.

A script should treat the warning as information. For a Short, check duration_seconds <= 180 after the call and decide whether anything shorter than, say, 15 seconds is worth posting.

Why the clamp is useful for Shorts

A Short can be up to three minutes, but your sources are different lengths: 172.4 seconds, 95 seconds, 214 seconds. Without a clamp you would need to probe each file before you could choose an end. With it, one request shape works for all of them: start 0, end 180. The 214-second file is cut to 180 with no warning; the 95-second file comes back whole with the warning. A downstream step can then branch on warnings[] instead of on a separate probe call.

Keep in mind what the clamp does not do. It does not pick a good out-point, so a hard cut at 180 can land mid-word. And it does not change the 900-second output limit or the 1,800-second source limit; a longer source fails with source_duration_exceeded. For those, trim a section first and then cut again from the artifact.

A batch pattern

For a folder of sources of unknown length, request start 0, end 180 for each, then sort by the returned duration_seconds. Anything with the warning is shorter than three minutes and already fits a Short. Anything without it was cut at exactly 180 seconds and might need a better out-point than a hard cut.

If you would rather fail than clamp, use duration instead of end and compare the returned duration_seconds with what you asked for. With either pattern, send a distinct Idempotency-Key per source, or the second request will return the first job.

Sources

Related posts

More in Media tools

All Media tools posts

Written by Sume