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.

5 min readSume
All posts

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 errs

What 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

All Developers posts

Written by Sume