Skip to content
中文

Request HLS renditions

Code Mode: praxis.media.libraries.assets.hls.create

HTTP: POST /media/v1/libraries/{library_id}/assets/{asset_id}/hls

Build a video asset’s adaptive HLS ladder for its current version, so one asset plays at several clarities on an ordinary player. Use library_id from creation or listing and the asset_id of a video asset; the ladder belongs to the version the asset has now, and a later version gets its own. heights names the rungs to build: a non-empty subset of 480, 720 and 1080 with no repeats, or omitted to build all three. The ladder never upscales — a rung above the source’s short side is dropped, and a list entirely above it keeps its lowest rung. The call is asynchronous and starts paid transcoding: the work runs as the video-transcode-hls model, one piece per rung per ten minutes of source, and it is charged per output minute at that model’s published price to the organization that owns the asset (ADR-146 §5) — a rung the source cannot carry, and a failed rung, are not charged. A source longer than eight hours (28800 seconds) is refused with SOURCE_TOO_LONG before anything is planned. Repeating the call is safe: a rung already processing, ready or failed is left as it is and is never encoded twice. The response is 202 with the asset_id, its current version and one entry per rung — name, height, width, bitrate, bytes and state, where processing means the rung is still being encoded, ready means it plays and failed means it gave up and can be retried by asking again. Poll GET /media/v1/libraries/{library_id}/assets/{asset_id}/hls until every rung is ready, then play the ladder through the content service, which mints the short-lived play address. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/hls with {“heights”:[480,720,1080]}.

Signature

praxis.media.libraries.assets.hls.create(args:{path:{library_id:string;asset_id:string};body:{/** The clarity rungs to build: a non-empty subset of 480, 720 and 1080 with no repeats. e.g. [480,720,1080] */ heights?:Array<480|720|1080>}}):Promise<{/** The video asset this ladder belongs to. */ asset_id:string;/** The asset version the ladder was built for; a later version gets its own ladder. */ version:number;/** One entry per rung recorded for this version, ascending by height; an asset whose ladder was never requested, and an asset that is not a video, answer an empty */ renditions:Array<{/** Clarity rung as its playlist calls it; the height with a p, so 480p is the short side at 480 pixels. */ name:"480p"|"720p"|"1080p";/** Short side of this rung in pixels. */ height:480|720|1080;/** Width of this rung’s first encoded piece, read from that piece’s own index; null while no piece has finished indexing. */ width:number|null;/** Average bitrate of this rung in bits per second, computed from the encoded segments the same way the master playlist’s AVERAGE-BANDWIDTH is; null while nothing */ bitrate:number|null;/** Stored size of this rung so far, in bytes, counting the pieces that are indexed (init segments included); it grows as pieces finish. */ bytes:number;/** Readiness of this rung: processing while any piece is pending or running, ready when every piece is ready, failed when any piece gave up. */ state:"processing"|"ready"|"failed"}>}>;

Parameters

NameInTypeRequiredDescription
library_idpathstringyesLibrary ID returned by creation.
asset_idpathstringyes32-character asset ID.

Request body

RequiredContent typesDescription
yesapplication/json

Responses

StatusContent typesDescription
202application/jsonSuccessful response.
400application/jsonA selector, cursor, limit or other parameter is invalid; correct the reported field before retrying.
402application/jsonRequest failed; see the error code reference.
403application/jsonThis credential has read-only access to the library; use a write-capable binding for mutations.
404application/jsonThe library or asset is missing, deleted or belongs to another tenant; verify its identifier and owner.
409application/jsonRequest failed; see the error code reference.
413application/jsonThe file exceeds an input limit; provide a smaller source file.
415application/jsonThis media format is unsupported; provide a supported format.
422application/jsonRequest failed; see the error code reference.
429application/jsonA rate limit was reached; wait before retrying.
501application/jsonThe requested operation is unsupported; choose a supported method.
502application/jsonRequest failed; see the error code reference.
503application/jsonHistorical projections are still being initialized, or library storage is temporarily unavailable; retry shortly and check failureSummary counts_complete.