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]}.
签名
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"}>}>;参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| library_id | path | string | 是 | Library ID returned by creation. |
| asset_id | path | string | 是 | 32-character asset ID. |
请求体
| 必填 | 内容类型 | 说明 |
|---|---|---|
| 是 | application/json |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 202 | application/json | Successful response. |
| 400 | application/json | A selector, cursor, limit or other parameter is invalid; correct the reported field before retrying. |
| 402 | application/json | Request failed; see the error code reference. |
| 403 | application/json | This credential has read-only access to the library; use a write-capable binding for mutations. |
| 404 | application/json | The library or asset is missing, deleted or belongs to another tenant; verify its identifier and owner. |
| 409 | application/json | Request failed; see the error code reference. |
| 413 | application/json | The file exceeds an input limit; provide a smaller source file. |
| 415 | application/json | This media format is unsupported; provide a supported format. |
| 422 | application/json | Request failed; see the error code reference. |
| 429 | application/json | A rate limit was reached; wait before retrying. |
| 501 | application/json | The requested operation is unsupported; choose a supported method. |
| 502 | application/json | Request failed; see the error code reference. |
| 503 | application/json | Historical projections are still being initialized, or library storage is temporarily unavailable; retry shortly and check failureSummary counts_complete. |