Expand description
Per-segment encoder worker: pop a chunk → encode K frames → emit one CMAF segment file → repeat.
v2 multi-GPU model (2026-05-11): each worker owns one GPU lease
and one encoder for its lifetime, but builds a fresh
CmafVideoMuxer per claimed segment. The muxer is configured
with the segment’s index + base decode time so the on-disk
filename + tfdt match what a single-encoder pipeline would
produce. Helpers attaching mid-flight just start popping from
the queue’s current head; no decode-and-discard.
Workers exit when queue.pop() returns None (pump closed +
queue drained). The returned WorkerOutput lists every segment
the worker wrote so the orchestrator can merge contributions
into the per-rung manifest.
Structs§
- Chunk
Packets - One chunk’s encoded packets, in encode (= display, no B-frames) order.
- Encoder
Worker Config - Rung
Codec Invariant - Mandatory AV1 sequence-header fields that every encoder contributing segments to a single rendition MUST agree on.
- Worker
Output
Enums§
- Invariant
Check - Outcome of comparing a worker’s first packet against the rung’s
codec invariant. The caller —
run_encoder_worker_blocking— branches on this to decide whether to keep encoding, soft-fail (requeue the chunk for another worker), or hard-fail (parse error from a malformed bitstream).
Functions§
- run_
chunk_ encoder_ worker_ blocking - Encoder worker that COLLECTS packets per chunk (single-file path). Each
chunk is encoded by a fresh encoder (first frame an IDR); the cross-vendor
codec invariant is enforced on the first packet (mismatch → requeue + exit,
exactly like the CMAF worker). Ordered
ChunkPacketsare pushed toout. - run_
encoder_ worker_ blocking - Run the encoder loop until the chunk queue is closed and drained.
Designed to be wrapped in
tokio::task::spawn_blocking. - validate_
or_ set_ rung_ invariant - Parse a worker’s first packet, derive the codec invariant, and
compare-or-set it against the per-rung slot. Returns
InvariantCheckon a successful parse; anErronly on malformed bitstream (the encoder failed to emit anOBU_SEQUENCE_HEADERat all, which is a configuration bug that nothing downstream can recover from).