Log segment count and billable minutes per holiday ad

Read segment_count, billable_minutes, and warnings from each Sume timeline render result and log one cost line per holiday ad. A Python script, no network.

5 min readSume
All posts

A completed Sume timeline render returns kind: timeline_render with video_url, duration_seconds, segment_count, billable_minutes, and optional warnings[]. Write those into one line per ad and you have a cost log for the holiday run. The rate is $0.10 per billable minute, so the cost of an ad is billable_minutes times 0.10.

The result fields come from Timeline 1.0 and the polling steps from Jobs and results (read 2026-10-06). The script reads the result JSON from standard input, so it needs no key and runs offline.

What does one result look like?

Fetch it with GET /v1/jobs/:id/result after the job status is completed. A plan can predict minutes, but not padding or looping, so the render's own warnings are the record of what actually happened.

Fields the log keeps (read 2026-10-06)
FieldMeaning
duration_secondsLength of the rendered MP4
segment_countNumber of video slots rendered
billable_minutesOutput minutes billed, rounded up
warnings[].codeSoft degradations such as snapped transitions

How do I turn it into a log line?

Pass the ad name as the first argument and pipe the result in. The script accepts the result as is, or wrapped in a result key.

import json, sys

RATE_USD_PER_MINUTE = 0.10

def log_line(ad_name, result):
    result = result.get("result", result)
    minutes = result["billable_minutes"]
    warnings = [w.get("code", "?") for w in result.get("warnings", [])]
    return ",".join([
        ad_name,
        str(result["duration_seconds"]),
        str(result["segment_count"]),
        str(minutes),
        f"{minutes * RATE_USD_PER_MINUTE:.2f}",
        "|".join(warnings),
    ])

if __name__ == "__main__":
    print("ad,duration_seconds,segment_count,billable_minutes,cost_usd,warnings")
    print(log_line(sys.argv[1], json.load(sys.stdin)))

What should I do with the warnings?

Warnings are soft degradations, not failures: the render still returns a video. Keep the codes in the log so you can spot a pattern, such as a clip that is always padded.

  • A list of ads with the same warning usually shares a source clip that is too short.
  • Add the job id to the line if you want to trace it, and keep the idempotency key of the request next to it.
  • Cost is a rate times minutes. Confirm the live rate in GET /v1/catalog before you trust the constant.

Sources

Related posts

More in Use cases

All Use cases posts

Written by Sume