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/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 fc88cc6..6113be9 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); }); });