Revert "fix(capture): skip video-only pre-roll in standby to stop A/V pitch drift"

This reverts commit 51b66d882f.
This commit is contained in:
Zac Gaetano 2026-06-04 04:28:11 +00:00
parent 51b66d882f
commit b28393eb76

View file

@ -1078,26 +1078,13 @@ exit "$BMXRC"
if (sourceAudioChannels && wantAudioChannels) audioChannels = effAudioChannels;
// ── Pre-roll: discard initial unstable frames ────────────────────────────
// CRITICAL A/V-SYNC NOTE: this drains ONLY the VIDEO pipe (fc_pipe stdout).
// The audio FIFO is opened by ffmpeg, not here, so it keeps BUFFERING during
// the drain — when ffmpeg starts it reads that buffered pre-roll audio,
// making the audio stream ~PRE_ROLL_SECONDS longer than video. Synced to the
// video length that surplus audio is compressed → a slight pitch-up.
//
// In STANDBY mode the framecache slot has been warm for a long time, so there
// are NO unstable startup frames to discard — skip the asymmetric drain
// entirely and let ffmpeg open video (fc_pipe) and audio (FIFO) together so
// both streams start from the same instant. Only the legacy on-demand spawn
// (cold slot) still needs the brief drain.
if (bridgeProcess && !_standbyMode
&& (sourceType === 'deltacast' || sourceType === 'blackmagic' || sourceType === 'sdi')) {
if (bridgeProcess && (sourceType === 'deltacast' || sourceType === 'blackmagic' || sourceType === 'sdi')) {
console.log(`[capture] pre-rolling: discarding ${PRE_ROLL_SECONDS}s of frames`);
bridgeProcess.stdout.on('data', () => {});
// Attach temporary drain listener.
bridgeProcess.stdout.on('data', () => {});
await new Promise(r => setTimeout(r, PRE_ROLL_SECONDS * 1000));
bridgeProcess.stdout.removeAllListeners('data');
console.log(`[capture] pre-roll complete.`);
} else if (bridgeProcess) {
console.log('[capture] standby/warm slot — skipping video-only pre-roll to keep A/V aligned');
}
const startedAt = new Date().toISOString();