From 704769064781acf61037203c500f9115deb6387d Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Sun, 5 Jul 2026 12:49:23 +0300 Subject: [PATCH] fix: resync video_index to MXL clock to prevent falling behind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After each video frame sleep, use mxlGetCurrentIndex instead of a simple +1 increment — if audio processing ate into the next frame's time we now skip the stale index rather than writing a late grain. Same pattern ndiin already uses. Co-Authored-By: Claude Sonnet 4.6 --- nodes/videoin/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nodes/videoin/main.cpp b/nodes/videoin/main.cpp index 0361a42..63f1d57 100644 --- a/nodes/videoin/main.cpp +++ b/nodes/videoin/main.cpp @@ -117,7 +117,7 @@ class VideoInNode : public dmf::NodeBase { if (has_video) { const uint64_t ns = mxlGetNsUntilIndex(video_index + 1, &video_rate); if (ns > 0 && ns < 2'000'000'000ULL) mxlSleepForNs(ns); - video_index++; + video_index = mxlGetCurrentIndex(&video_rate); } } else if (frame_kind == dmf::VideoReader::FrameKind::Audio) { if (has_video && vst == MXL_STATUS_OK) mxlFlowWriterCancelGrain(video_writer); @@ -159,6 +159,10 @@ class VideoInNode : public dmf::NodeBase { } mxlFlowWriterCommitSamples(audio_writer); audio_index += out_samples_written; + if (has_video) { + const uint64_t current = mxlGetCurrentIndex(&video_rate); + if (current > video_index) video_index = current; + } } }