Mux direct upload chunks: multiples of 256 KB, UpChunk at ~5 MB

Mux direct uploads need chunks in multiples of 256 KB; UpChunk sends about 5 MB. A chunk-size helper and the upload states to wait on before using an asset.

4 min readSume
All posts

If you stream a file to a Mux direct upload yourself instead of using a client library, each chunk must be a multiple of 256 KB. Mux's UpChunk library uploads in about 5 MB pieces, and the page's streaming example uses 8 MB. The docs do not state a maximum file size, so do not plan around a number we cannot cite. The helper below snaps any target chunk size to the 256 KB rule.

Facts from the Mux page

Mux direct upload guide, read 2026-10-02
ItemWhat the page says
Chunk ruleMultiples of 256 KB
UpChunkUploads in about 5 MB chunks
Streaming example8 MB chunks
cors_originA domain, or * for any
new_asset_settingsIncludes playback_policy, video_quality, passthrough
Upload stateswaiting_for_upload, ready, cancelled_upload
Eventsvideo.upload.asset_created, video.asset.created, video.asset.ready, video.upload.cancelled

A chunk-size helper

UNIT = 256 * 1024

def chunk_size(target_bytes):
    if target_bytes < UNIT:
        raise ValueError("chunk must be at least 256 KB")
    return (target_bytes // UNIT) * UNIT

def plan(total, target=8 * 1024 * 1024):
    size = chunk_size(target)
    return [(i, min(i + size, total) - 1) for i in range(0, total, size)]

print(chunk_size(5_000_000))
print(plan(20 * 1024 * 1024))

Wait on the right event

An upload is not an asset you can play. After the last chunk, wait for video.asset.ready before you link the video anywhere. The passthrough setting lets you tag the upload with your own id; if the file came from Sume, put the job id there so the Mux asset traces back to the render that made it.

Preparing the file

A smaller input means fewer chunks and a faster ready event. Video trim cuts a range ($0.02 per job; output up to 900 seconds) and, in exact mode, conforms width, height (256 to 2160) and fps (24, 25, 30 or 60). Probe the result with video inspect for probe.size_bytes before you plan the chunks.

Retry behaviour

Chunked uploads fail in the middle more often than whole-file ones, so plan to resend a single chunk rather than the file. Keep the plan list from the helper, record the index of the last accepted chunk, and resume from there. The page documents a cancelled state, so if your user abandons the upload, let the upload end in cancelled_upload instead of leaving it waiting. Remember that the asset only exists after the first asset event, so do not store a playback id before then.

Limits

The helper only handles the chunk rule. It does not do the HTTP Content-Range bookkeeping, retries, or the creation of the upload URL, all of which Mux documents elsewhere. Sume has no bitrate or codec field, so file size is steered only by length and frame size.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume