X media upload: how many APPEND calls a Sume MP4 needs at 5 MB

X's chunked upload keeps each segment at or below 5 MB, with an 8 MB server limit. Divide your MP4's byte size by 5 MB, rounded up, to count APPEND calls.

4 min readSume
All posts

Round the file size up to whole 5 MB segments: a 120 MB MP4 needs 24 APPEND calls and a 121 MB one needs 25. X's chunked upload page says to keep each segment at or below 5 MB and notes that the server limit is 8 MB. The flow is INIT at POST /2/media/upload/initialize, then APPEND at /2/media/upload/{id}/append, then FINALIZE, then STATUS polling if processing is needed.

X v2 chunked upload steps and limits (read 2026-10-13)
StepEndpoint or rule
INITPOST /2/media/upload/initialize with media type, total bytes and category
APPENDPOST /2/media/upload/{id}/append, each segment at or below 5 MB
FINALIZEPOST /2/media/upload/{id}/finalize
STATUSPoll while processing: pending, in_progress, succeeded or failed
Video limitsDefault 20 minutes and 8 GB; Premium/verified 125 minutes and 16 GB

Where the Sume file fits

A finished Timeline 1.0 job returns a video_url. Download it, read its byte length and use that as the total bytes in INIT. Sume does not document the size of its renders, so the count is only known after the job. The media category for a post video is tweet_video.

If a video is longer than the posting account allows, attaching it to a post can return 403 even though the upload succeeded. Keep the render within 1200 s for a default account, or 7500 s for Premium, and you avoid that surprise.

Counting segments

The function divides by 5 MB using the 5 x 1024 x 1024 byte reading; use the decimal reading instead if you prefer a safer margin. Neither is a statement about which one X enforces, so the page's phrase "at or below 5 MB" is the only rule.

import math

SEGMENT = 5 * 1024 * 1024

def append_calls(total_bytes):
    return math.ceil(total_bytes / SEGMENT)

print(append_calls(120 * 1024 * 1024))   # 24
print(append_calls(121 * 1024 * 1024))   # 25

Sources

Related posts

More in Developers

All Developers posts

Written by Sume