Tune transcoding performance
Start with the local CPU pipeline, then change one setting at a time and observe frame-budget metrics. A host's channel capacity depends on its source formats, rendition sizes, frame rates, filters, and encoder choices.
Select the device and codecs
transcoders.device accepts cpu, nvidia, netint_quadra, netint_t4xx,
qsv and vaapi; omission allows automatic selection. Availability depends on the build,
host driver and container device access. QSV and VAAPI join automatic selection only
when opted in; see Intel QSV and AMD VAAPI.
encoder_name selects a concrete encoder implementation per rendition; decoder.name
selects a decoder.
[[transcoders]]
id = "encode"
source_ids = ["input"]
device = "cpu"
[[transcoders.tracks]]
id = "video"
type = "video"
track_selector = { type = "track-kind", kind = "video" }
processing = { hw_filtering_enabled = false, max_frame_rate = [30, 1] }
[[transcoders.tracks.renditions]]
id = "preview"
codec = "h264"
encoder_name = "libx264"
bit_rate = 800_000
size = { width = 640 }
gop_size_ms = 1000
options = { preset = "veryfast" }
decoder.hw_frames_enabled and processing.hw_filtering_enabled default to
true; disable them when you need software frames/filters. A CPU/GPU boundary
can require frame copies and format conversion. The browser overlay recipes
show separate CPU and NVIDIA paths.
Software encoders
| Encoder | Codec | Images |
|---|---|---|
libx264 | H.264 | Image variants with x264/x265 only |
libx265 | HEVC (Main, Main 10) | Image variants with x264/x265 only |
libsvtav1 | AV1 | All images with bundled FFmpeg |
On the standard image, encode with a hardware encoder or
libsvtav1. The Packager applies low-latency defaults to these encoders:
| Encoder | Defaults |
|---|---|
libx264 | preset=veryfast, tune=zerolatency, sc_threshold=0; profile=baseline for 8-bit 4:2:0 input |
libx265 | preset=ultrafast, tune=zerolatency, x265-params=pools=<threads> |
libsvtav1 | preset=11, svtav1-params=pred-struct=1:rc=2:irefresh-type=2 plus lp=<n> from the thread budget |
libx264 and libx265 also get forced-idr=1 when
gop_alignment is set. The SVT-AV1 parameters select
no frame reordering, CBR rate control and closed-GOP keyframes. Options set on the rendition
take precedence. A rendition's own x265-params or svtav1-params merges with the defaults
key by key, so a pools or lp set there is kept.
[[transcoders.tracks.renditions]]
id = "video-1080p-av1"
codec = "av1"
encoder_name = "libsvtav1"
gop_size_ms = 1000
bit_rate = 2_000_000
size = { width = 1920, height = 1080 }
Thread budgets
| Environment variable | Unset behavior | What zero means |
|---|---|---|
PACKAGER_WORKER_THREADS | Caps the control and worker thread pools at 4 threads each, or host parallelism if lower. | Host parallelism. |
PACKAGER_ENCODER_THREADS | libx264, libx265 and libsvtav1 default budget: 1; 4 for targets above 1920×1080×60 pixels/second. | The encoder's own thread selection. |
PACKAGER_FILTER_THREADS | 1 software filter slice thread. | libavfilter automatic selection. |
PACKAGER_DECODER_THREADS | 1 decoder thread. | FFmpeg automatic selection. |
Values must be integers from 0 through 512; invalid environment values abort
startup. The worker cap applies to the control and worker pools; media
threads follow the encoder, filter and decoder budgets. The encoder
variable is a floor: setting it to 2 leaves high-pixel-rate targets at 4.
It applies to libx264, libx265 and libsvtav1; hardware encoders have their own thread
models. libx265 receives the budget as its thread pool size (pools). libsvtav1 receives
it as its parallelism level (lp).
Explicit rendition thread and decoder thread settings override their
respective defaults; processing.filter_threads overrides the filter default.
A thread block needs count to express an override. count = 0 requests library
automatic selection. processing.filter_threads must be positive: use the
environment variable, not filter_threads = 0, for filter auto-selection.
Decoder low-delay mode uses slice threading even when frame threading is
requested; frame threading can add latency.
[transcoders.tracks.renditions.thread]
kind = "slice"
count = 2
Frame rate, GOPs, and rate control
processing.deinterlace defaults to every_field for interlaced content, which
can double output frame rate. every_frame keeps one output frame per input
frame; disabled retains interlacing. Progressive input is unaffected.
max_frame_rate = [30, 1] caps the processed rate.
processing.gop_alignment = "match_incoming" follows incoming GOP boundaries;
gop_alignment = { aligned = { gop_size_ms = 1000 } } places a keyframe on every
1000 ms boundary of the frame timestamps, so renditions and separate packagers fed the
same timeline agree on keyframe positions. See GOP alignment.
Choose GOPs with downstream segmenting and latency requirements in mind.
For bitrate-offset semantics, buffer sizing and pixel formats, see the
configuration reference.
If frame processing repeatedly exceeds one frame duration, first inspect which stage is slow. Reduce rendition count/size, simplify filters, or select a faster encoder preset before increasing thread budgets across every process on a host.