Python pre-flight for a Short: catch Timeline schema errors offline
A Python check for a Sume Timeline body: even width and height, allowed fps, 1 to 1800 seconds, fade limits and start order. Run it before the plan call.

Most Timeline 400s for short-form video come from a handful of rules you can check locally: width and height even and between 256 and 2160, fps one of 24, 25, 30 or 60, duration_seconds from 1 to 1800, fades of 0 to 5 seconds that fit, and video[0].start equal to 0 with strictly increasing starts. The script below checks those rules, taken from the Sume Timeline docs on 2026-10-06. It does not replace the server: the unbilled plan call is the authority.
What does the check look like?
def check(body):
errs, out = [], body.get("output", {})
a, v = body.get("audio", {}), body.get("video", [])
for k in ("width", "height"):
n = out.get(k)
if n is not None and not (isinstance(n, int) and 256 <= n <= 2160 and n % 2 == 0):
errs.append(k + " must be an even integer 256-2160")
if not 1 <= a.get("duration_seconds", 0) <= 1800:
errs.append("duration_seconds must be 1-1800")
if not 1 <= len(v) <= 200:
errs.append("video needs 1-200 slots")
if v and v[0].get("start") != 0:
errs.append("video[0].start must be 0")
if any(y["start"] <= x["start"] for x, y in zip(v, v[1:])):
errs.append("starts must increase")
if out.get("fps", 30) not in (24, 25, 30, 60):
errs.append("fps must be 24, 25, 30 or 60")
fi, fo = out.get("fade_in_seconds", 0), out.get("fade_out_seconds", 0)
if not (0 <= fi <= 5 and 0 <= fo <= 5 and fi + fo <= a.get("duration_seconds", 0)):
errs.append("fades must be 0-5 s and fit")
return errsWhat does it not cover?
Host rules (every URL must be a media.sume.com artifact of your workspace), transition fit and source lengths need the server. Those surface from the plan call or as warnings in the result, so run the plan call after this check and before the paid render.
Sources
Related posts
More in Developers
- Python: run one prompt on four AI video models and save the clips
A Python script that sends one prompt to Wan 3.0, Seedance 2.5, Kling 3 and MiniMax H3 on Sume, polls all four jobs and saves each MP4, with costs.
- Python TTS cost calculator: Sume job rounding vs per-character rates
A runnable Python function that prices narration lines on Sume (cent rounding, 1-cent minimum) and at flat per-million rates for MAI-Voice-2.1 and Flash.
- R httr2: submit an AI video job, poll it, and save the MP4 (Wan 3.0)
An R script posts a Wan 3.0 job to Sume with httr2, loops on /v1/jobs/{id}/status using next_poll_after_seconds and writes the finished clip to disk.
- Rails Sidekiq job that polls an AI video API with perform_in
A Sidekiq worker reads Sume's /v1/jobs/{id}/status once, then reschedules itself with perform_in using next_poll_after_seconds until the job is terminal.
Written by Sume