Video trim end past the clip: trim_clamped_to_source and a short ad

If end is beyond the source, Sume video-trim clamps it and warns trim_clamped_to_source. Ask for 0-20 s of a 15 s clip and you get 15 s, which can break a spot.

5 min readSume
All posts

If end is after the end of the source, Sume video trim does not fail. It clamps the range to the source and puts the warning trim_clamped_to_source in the result. So a request for start: 0, end: 20 on a 15-second clip returns a 15-second MP4 as a successful job, and a script that only checks for errors would pass it on. If your target is a 20-second spot, read duration_seconds in the result.

What the API does with a range

Video trim 1.0 takes one Sume-hosted clip and exactly one of end or duration. The output is a new MP4 and costs $0.02 a job. The limits from the docs (read 2026-10-08) are below.

Video trim range rules (read 2026-10-08)
CaseResult
start: 0, end: 20 on a 15 s sourceClamped to 15 s; warning trim_clamped_to_source
end and duration both sentRefused: video_trim_range_conflict
Neither end nor durationRefused: video_trim_range_required
end <= start, or range longer than 900 sRefused: video_trim_range_empty
duration below 0.2 sOutside the 0.2-900 s duration range
Source longer than 1,800 sRefused by the worker: source_duration_exceeded

Why it matters for ad specs

Platform specs have both a floor and a ceiling. The TikTok page (read 2026-10-08) allows up to 10 minutes for non-Spark ads, and it sets 540x960 and 516 kbps as minimums. The page facts used here give no minimum length, but a creative brief often does. A clamp silently turns a 20-second brief into a 15-second file. The fix is a check in your code, and it is two lines: compare duration_seconds with what you asked for, and compare the list of warnings.

import math

def trim_ok(result: dict, asked_seconds: float) -> bool:
    warned = any("trim_clamped_to_source" in str(w) for w in result.get("warnings", []))
    return not warned and math.isclose(
        result["duration_seconds"], asked_seconds, abs_tol=0.1
    )

print(trim_ok({"duration_seconds": 15.0, "warnings": [{"code": "trim_clamped_to_source"}]}, 20))
print(trim_ok({"duration_seconds": 20.0}, 20))

Reading the result

A finished trim returns kind: video_trim with video_url, duration_seconds, actual_start_seconds, precision, audio, output and the optional warnings[]. Three fields tell you whether the file is the one you asked for. duration_seconds is the real length. actual_start_seconds is the real in-point, which can differ from start under precision: keyframe. warnings[] lists soft problems such as the clamp. A job that carries a warning is still a finished job, billed at $0.02, so a retry costs another $0.02. Fix the request before you retry, or you will pay twice for the same short file.

  • Asked 20 s, got 15 s: the source was 15 s. Check the clip, not the API.
  • Asked 20 s from start: 10, source 15 s: the cut is 5 s long, so the clamp is larger than it looks.
  • The check costs nothing: a probe with frames: false reads the duration first.

Use `duration` when you want a length

With duration you state the length you want, and with end you state a point in the source. For a fixed-length cutdown, duration reads more clearly. Combine it with video_inspect first if you do not know the source length: a probe with frames: false is enough, and it gives the duration before you pay the $0.02. The warnings[] field is optional, so treat a missing field as no warnings.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume