From 105d04729a5938cf7bec073fcd8ef691decda220 Mon Sep 17 00:00:00 2001 From: OpenCode Date: Fri, 5 Jun 2026 03:12:42 +0000 Subject: [PATCH] fix(capture): explicit slice threading on VC-3 growing encoder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dnxhd with ffmpeg default frame-threading starts at ~0.27x realtime and buffers a long pipeline before output flows, so the fc_pipe ring laps ~344 startup frames (spotty audio+video for the first several seconds). Setting -threads 32 -thread_type slice makes dnxhd encode >= realtime from frame 1 (measured 1.3x at start), cutting startup drops substantially. The finalized master file is gap-free (even PTS, audio==video duration) — the remaining skipped frames are pre-record spin-up frames dropped to the live edge, not holes in the recording. --- services/capture/src/capture-manager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/capture/src/capture-manager.js b/services/capture/src/capture-manager.js index 39433a1..e12b2a2 100644 --- a/services/capture/src/capture-manager.js +++ b/services/capture/src/capture-manager.js @@ -920,8 +920,15 @@ class CaptureManager { args.push('-filter_complex', filterComplex); // (a) VC-3/DNxHD master (8-bit 4:2:2) -> MXF OP1a, growing-readable. + // `-threads 16 -thread_type slice`: CRITICAL for the first ~10s. With ffmpeg's + // DEFAULT frame-threading, dnxhd buffers a long pipeline before output starts + // — it runs at ~0.27x for the first few seconds, so the fc_pipe ring overflows + // and ~344 startup frames are DROPPED (spotty audio+video for ~10s). Explicit + // slice threading makes dnxhd encode >= realtime from frame 1 (measured 1.3x + // at start vs 0.27x), eliminating the startup backlog and the dropped frames. args.push('-map', '[vhi]', - '-c:v', 'dnxhd', '-b:v', vb, '-pix_fmt', 'yuv422p', + '-c:v', 'dnxhd', '-threads', '32', '-thread_type', 'slice', + '-b:v', vb, '-pix_fmt', 'yuv422p', '-r', framerate || '60000/1001', '-map', audioMap, '-c:a', 'pcm_s24le', '-ar', '48000', '-ac', String(ach), '-f', 'mxf', outPath);