Extract 6 thumbnail candidates from a clip with video-frames
Send POST /v1/video-frames with an at list of up to 24 timestamps and get durable image URLs at source size. Python polling example, formats and limits.
To pull thumbnail candidates, POST video_url and an at list of up to 24 timestamps to /v1/video-frames. The job returns 202, and when resource_status is ready each frame is a durable media.sume.com image with t, url, width and height (Video frames). Frames keep the source size unless you send max_edge.
Python, end to end
The clip must already be on media.sume.com. The submit always returns 202, so there is no sync mode to ask for.
import os, time, requests
API = "https://api.sume.com"
h = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}
r = requests.post(API + "/v1/video-frames", headers={**h, "Idempotency-Key": "thumbs-001"}, json={
"video_url": "https://media.sume.com/artifacts/artf_demo/talk.mp4",
"at": [1, 4, 8, 12, 16, 20],
"format": "jpeg",
"max_edge": 1280,
})
rid = r.json()["request_id"]
while True:
o = requests.get(API + "/v1/video-frames/" + rid, headers=h).json()["video_frames"]
if o["resource_status"] == "ready":
break
time.sleep(2)
for f in o["frames"]:
print(f["t"], f["url"])Parameters
| Field | Value |
|---|---|
at[] | 1 to 24 values, each 0 <= t < duration |
format | jpeg (default) or png |
max_edge | 16 to 2160, optional long-edge clamp |
| Source length | Up to 300 s |
Behaviour worth knowing
- If one instant fails to extract, that frame's
urlisnulland the job still succeeds. - A timestamp at or past the duration fails the job with
frame_time_out_of_range. - Billing follows the job's Modal compute, never more than the hold reserved at submit.
Sampling with fps instead of a list
Send fps instead of at[] when you do not know where the good frames are. It must be above 0 and at most 2, and Sume expands it to mid-bin samples at 0.5/fps, 1.5/fps and so on, capped at 24 frames per call. At fps: 0.5 a 20-second clip yields frames at 1, 3, 5 ... 19 seconds, ten candidates.
Send only one of at or fps. The source can be at most 300 seconds. The job reserves its Modal compute ceiling at submit and bills the actual compute, never more than the hold.
Sources
Related posts
More in Media tools
- Extract the first 90 seconds of a video's audio: audio-detach range
Send audio-detach range {start 0, end 90} for $0.01: 17.28 MB as 48 kHz stereo wav or 1.44 MB as 128 kbps mp3, a Shorts Audio Library song's 90 s.
- Five caption looks on one clip: one transcription, four restyles
Test five caption styles on one video for $1.00: the first job transcribes, four source_caption_id restyles reuse the word timings. Request bodies included.
- Five people in the clip: Recast takes four photos, 12 s costs $4.50
H3 Max Recast on Sume accepts 1 to 4 person photos. A five-person source needs a plan: a 12-second clip is 12 x $0.375 = $4.50 at 768p.
- video-frames fps limit: 24 frames, fps up to 2, what it covers
Sume video-frames takes fps from just above 0 up to 2 and caps each call at 24 frames at mid-bin times. Table of sample times and the span 24 frames reach.
Written by Sume