mirror of
https://github.com/myronblair/kino-app
synced 2026-07-28 13:33:49 -05:00
Fix ABR thread cap actually stacking per variant instead of capping total
Setting -threads:v:i to the full TRANSCODE_THREADS on every variant let each of the (up to 4) ABR renditions ask for the full budget independently -- confirmed live on CT104: ffmpeg was still pulling ~7 of 8 cores despite the "cap". Now divides the budget across however many variants are in this job (6 threads / 4 variants = ~1-2 each), so the total stays near the intended cap regardless of source resolution.
This commit is contained in:
@@ -93,14 +93,19 @@ async def transcode_abr(source: Path, out_dir: Path, on_status: Callable[..., Aw
|
||||
fc_parts.append(f"[v{i}]scale=w=-2:h={h}[v{i}out]")
|
||||
filter_complex = ";".join(fc_parts)
|
||||
|
||||
cmd: List[str] = ["nice", "-n", str(TRANSCODE_NICE), "ffmpeg", "-y", "-threads", str(TRANSCODE_THREADS), "-i", str(source), "-filter_complex", filter_complex]
|
||||
# Per-variant thread count, not the full cap each — x264 threads are set per encoder
|
||||
# instance, so giving every one of the (up to 4) variants the full TRANSCODE_THREADS
|
||||
# budget lets them all run near-full-tilt simultaneously and still saturate the host.
|
||||
per_variant_threads = max(1, TRANSCODE_THREADS // n)
|
||||
|
||||
cmd: List[str] = ["nice", "-n", str(TRANSCODE_NICE), "ffmpeg", "-y", "-threads", str(per_variant_threads), "-i", str(source), "-filter_complex", filter_complex]
|
||||
|
||||
for i, (_h, vb, maxr, buf, _ab) in enumerate(variants):
|
||||
cmd += [
|
||||
"-map", f"[v{i}out]",
|
||||
f"-c:v:{i}", "libx264",
|
||||
f"-preset:v:{i}", "veryfast",
|
||||
f"-threads:v:{i}", str(TRANSCODE_THREADS),
|
||||
f"-threads:v:{i}", str(per_variant_threads),
|
||||
f"-profile:v:{i}", "main",
|
||||
f"-pix_fmt:v:{i}", "yuv420p",
|
||||
f"-b:v:{i}", vb,
|
||||
|
||||
Reference in New Issue
Block a user