From 9aae4ef670ebbff9f99c3f70379ee4c8731ece72 Mon Sep 17 00:00:00 2001 From: Arjen Bloemsma Date: Wed, 18 Nov 2026 19:33:57 +0000 Subject: [PATCH 1/2] Fail the camera check when frames go missing --- README.md | 2 +- tests/camera_check.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c672c3..fdcab6e 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The recording engine forwards native camera frames and one shared microphone PCM A synchronization regression test encodes and decodes matching flashes and audio clicks with delayed delivery, including events just before Pause and Finish. It checks event alignment within 10 ms, rather than only comparing stream durations. -Run `./bin/test-camera` explicitly for a short real camera/microphone recording with a pause and resume. It uses separate `monologue-camera-check` settings and storage, and retains its output for inspection. It is never run by `bin/test`. +Run `./bin/test-camera` explicitly for a short real camera/microphone recording with a pause and resume. It fails when the clip holds fewer than 90% of the frames the camera delivered while recording. It uses separate `monologue-camera-check` settings and storage, and retains its output for inspection. It is never run by `bin/test`. A real-camera check is still needed for each device/backend combination, particularly maximum-resolution throughput and synchronization over long takes. Short 1920 × 1080 and 3840 × 2160 hardware checks passed on this machine; they do not establish physical lip sync or sustained throughput. diff --git a/tests/camera_check.cpp b/tests/camera_check.cpp index fc88cc6..92764c5 100644 --- a/tests/camera_check.cpp +++ b/tests/camera_check.cpp @@ -5,14 +5,28 @@ #include #include #include +#include +#include #include "backend.h" #include "mediautils.h" +// Video frames in the clip, counted by ffprobe; -1 when it cannot say. +static int clipFrames(const QString &path) { + QProcess probe; + probe.start("ffprobe",{"-v","error","-select_streams","v:0","-count_packets","-show_entries","stream=nb_read_packets","-of","csv=p=0",path}); + if(!probe.waitForFinished(10000) || probe.exitCode()!=0) return -1; + bool ok=false; const int frames=probe.readAllStandardOutput().trimmed().toInt(&ok); + return ok?frames:-1; +} int main(int argc,char**argv) { media::useFfmpeg(); QGuiApplication app(argc,argv); app.setOrganizationName("omacom"); app.setApplicationName("monologue-camera-check"); Backend backend; bool started=false; QString lastState; + // The preview receives every frame the camera delivers; count those that arrive while recording. + QVideoSink preview; int delivered=0; + backend.setPreview(&preview); + QObject::connect(&preview,&QVideoSink::videoFrameChanged,&app,[&] { if(backend.state()=="recording") ++delivered; }); QObject::connect(&backend,&Backend::changed,&app,[&] { if(backend.state()!=lastState) { lastState=backend.state(); QTextStream(stdout)<3.6 && backend.duration()<4.4 && backend.message().isEmpty()?0:1); + <<"Duration: "<=0.9*expected; + if(!keptFrames) QTextStream(stdout)<<"The clip holds fewer than 90% of the camera's frames."<3.6 && backend.duration()<4.4 && backend.message().isEmpty() && keptFrames?0:1); } if(backend.state()=="unavailable") QTimer::singleShot(0,&app,[&] { app.exit(1); }); }); From cbef2e5a857aaf33fde19a67b5ada2b401cfdaa8 Mon Sep 17 00:00:00 2001 From: Arjen Bloemsma Date: Wed, 18 Nov 2026 19:41:45 +0000 Subject: [PATCH 2/2] Compare against the rate the take is written at --- src/backend.h | 2 ++ tests/camera_check.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend.h b/src/backend.h index b488880..9404f1b 100644 --- a/src/backend.h +++ b/src/backend.h @@ -65,6 +65,8 @@ class Backend : public QObject { bool takeActive() const { return m_writer != nullptr; } bool dialogOpen() const { return m_dialogOpen; } double duration() const { return m_duration; } + // The rate takes are written at, which follows the selected camera mode. + double fps() const { return m_fps; } double level() const { return m_level; } double peakLevel() const { return m_peak; } bool clipping() const { return now() < m_clipUntil; } diff --git a/tests/camera_check.cpp b/tests/camera_check.cpp index 92764c5..6113be9 100644 --- a/tests/camera_check.cpp +++ b/tests/camera_check.cpp @@ -37,9 +37,9 @@ int main(int argc,char**argv) { QTimer::singleShot(5200,&backend,&Backend::finish); } if(backend.state()=="finished") { - // The take is written at up to 30 fps, so a faster camera is not expected in full. + // The take holds at most its own frame rate, so a faster camera is not expected in full. const int recorded=clipFrames(backend.clip().toLocalFile()); - const int expected=std::min(delivered,qRound(backend.duration()*30)); + const int expected=std::min(delivered,qRound(backend.duration()*backend.fps())); QTextStream(stdout)<<"Clip: "<