fix(capture): remove -use_wallclock_as_timestamps from framecache video input

The framecache ring delivers frame-accurate frames at exactly the SDI clock
rate. -use_wallclock_as_timestamps was wrong for this source — it stamped
frames by ffmpeg arrival time rather than capture time, causing the recorded
file to report wrong framerates (e.g. 56.06 instead of 59.94) and a
glitchy first second at startup (NVENC cold-start backlog bunched timestamps).

Fix: remove -use_wallclock_as_timestamps from the rawvideo (pipe:0) input
and rely on -framerate for correct CFR timestamps from frame 0.
Audio keeps its FIFO wallclock; aresample=async=1 on the master output
resamples audio to align with the CFR video PTS.
This commit is contained in:
Wild Dragon Dev 2026-06-03 22:30:03 +00:00
parent 7631527f46
commit a096226072

View file

@ -552,7 +552,8 @@ class CaptureManager {
return {
inputArgs: [
'-use_wallclock_as_timestamps', '1',
// No -use_wallclock_as_timestamps — framecache delivers CFR frames
// at the original ingest rate; -framerate produces correct timestamps.
'-thread_queue_size', '512',
'-f', 'rawvideo',
'-pix_fmt', 'uyvy422',
@ -680,16 +681,21 @@ class CaptureManager {
return {
inputArgs: [
// fc_pipe stdout → ffmpeg rawvideo input 0 (video)
// -use_wallclock_as_timestamps aligns video+audio by arrival time,
// same as the legacy FIFO path.
'-use_wallclock_as_timestamps', '1',
// DO NOT use -use_wallclock_as_timestamps here. The framecache ring
// delivers frame-accurate 60fps from the SDI clock, so -framerate
// produces correct CFR timestamps from frame 0, immune to ffmpeg
// startup jitter and NVENC cold-start. Wallclock timestamping caused
// wrong framerate in the recorded file (e.g. 56.06 instead of 59.94)
// because arrival-time jitter at ffmpeg startup skewed the PTS.
'-thread_queue_size', '512',
'-f', 'rawvideo',
'-pix_fmt', 'uyvy422',
'-video_size', fcSize,
'-framerate', fcFps,
'-i', 'pipe:0',
// Audio FIFO → ffmpeg input 1 (unchanged from legacy path)
// Audio FIFO → ffmpeg input 1. Keep wallclock on audio so A/V sync
// aligns by arrival time; aresample=async=1 (applied on the master
// output) resamples audio to match the video CFR timestamps.
'-use_wallclock_as_timestamps', '1',
'-thread_queue_size', '512',
'-f', 's16le',