fix: resync video_index to MXL clock to prevent falling behind

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 <noreply@anthropic.com>
This commit is contained in:
JohannesItten
2026-07-05 12:49:23 +03:00
parent fe6b7b10ed
commit 7047690647
+5 -1
View File
@@ -117,7 +117,7 @@ class VideoInNode : public dmf::NodeBase {
if (has_video) { if (has_video) {
const uint64_t ns = mxlGetNsUntilIndex(video_index + 1, &video_rate); const uint64_t ns = mxlGetNsUntilIndex(video_index + 1, &video_rate);
if (ns > 0 && ns < 2'000'000'000ULL) mxlSleepForNs(ns); 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) { } else if (frame_kind == dmf::VideoReader::FrameKind::Audio) {
if (has_video && vst == MXL_STATUS_OK) mxlFlowWriterCancelGrain(video_writer); if (has_video && vst == MXL_STATUS_OK) mxlFlowWriterCancelGrain(video_writer);
@@ -159,6 +159,10 @@ class VideoInNode : public dmf::NodeBase {
} }
mxlFlowWriterCommitSamples(audio_writer); mxlFlowWriterCommitSamples(audio_writer);
audio_index += out_samples_written; audio_index += out_samples_written;
if (has_video) {
const uint64_t current = mxlGetCurrentIndex(&video_rate);
if (current > video_index) video_index = current;
}
} }
} }