Dry-run a Sume video crop with video-filter check before a batch

POST /v1/video-filter/check validates a crop program without a job, credits or an encode. Run it first, then crop a batch of ad clips for new ratios.

5 min readSume
All posts

Before you crop a folder of ad clips, call POST /v1/video-filter/check. According to Sume's video filter docs, it runs the same schema, op and source checks as the encode, returns diagnostics, and does not create a job, reserve credits, boot a box or run the encoder. A program that passes can still fail on the box, so keep your error handling on the real encode.

Crop op rules

Crop rules from Sume's video filter docs (read 2026-10-05)
FieldRule
x, y0 to 1, fractions of the source frame
width, height0.05 to 1
Boundsx+width and y+height must be at most 1
RoundingEven values for yuv420p
Error codevideo_filter_crop_out_of_bounds

Check a 16:9 to 4:5 center crop

A 16:9 source cropped to 4:5 keeps (4/5)/(16/9) = 0.45 of the width and all the height. The offset that centers it is 0.275. The check call needs the source on media.sume.com.

import os, requests

API = "https://api.sume.com"
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
width = (4 / 5) / (16 / 9)
body = {"video_url": os.environ["SUME_VIDEO_URL"],
        "ops": [{"op": "crop", "x": round((1 - width) / 2, 4), "y": 0,
                 "width": round(width, 4), "height": 1}]}
r = requests.post(f"{API}/v1/video-filter/check", headers=H, json=body, timeout=30)
r.raise_for_status()
res = r.json()
print(res.get("valid"), res.get("next_action"), res.get("diagnostics"))

Then encode

When next_action is submit_video_filter, send the same body to POST /v1/video-filter with an Idempotency-Key, and read the result through the jobs endpoints.

Sources

Related posts

More in Media tools

All Media tools posts

Written by Sume