From a9dd4ee2640837e093757b86afc6b7035c117281 Mon Sep 17 00:00:00 2001 From: zii Date: Fri, 3 Apr 2026 08:21:10 -0400 Subject: [PATCH] v1.4 - EventLoop will now pick an image within 2 mins of live footage and copy it to the root directory of the buff dir. This can be used by user interfaces as a live stream thumbnail. - Gray option is no longer enabled by default. - The default compare command will now use the Gray image format internally instead of relying on the external Gray option. --- src/common.cpp | 4 ++-- src/common.h | 2 +- src/event_loop.cpp | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 2931ab1..cfd1be4 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -140,7 +140,7 @@ bool rdConf(const QString &filePath, shared_t *share) share->evtMax = 120; share->conf = filePath; share->outputType = "stderr"; - share->compCmd = "compare -metric FUZZ " + QString(PREV_IMG) + " " + QString(NEXT_IMG) + " /dev/null"; + share->compCmd = "compare -colorspace Gray -metric FUZZ " + QString(PREV_IMG) + " " + QString(NEXT_IMG) + " /dev/null"; share->vidCodec = "copy"; share->audCodec = "copy"; share->streamExt = ".ts"; @@ -150,7 +150,7 @@ bool rdConf(const QString &filePath, shared_t *share) share->liveMins = 60; share->liveClipSecs = 5; share->secPerImg = 4; - share->grayImg = true; + share->grayImg = false; share->recScale = "1280:720"; QString line; diff --git a/src/common.h b/src/common.h index 06da10d..a0f4438 100644 --- a/src/common.h +++ b/src/common.h @@ -32,7 +32,7 @@ using namespace std; -#define APP_VERSION "1.3" +#define APP_VERSION "1.4" #define APP_NAME "JustMotion" #define APP_TARGET "jmotion" #define DATETIME_FMT "yyyyMMddhhmm" diff --git a/src/event_loop.cpp b/src/event_loop.cpp index ce2d6a7..702bdaf 100644 --- a/src/event_loop.cpp +++ b/src/event_loop.cpp @@ -152,7 +152,7 @@ void EventItem::wroutThenDie() EventLoop::EventLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : QObject(parent) { shared = sharedRes; - heartBeat = 3; + heartBeat = 10; loopTimer = 0; connect(thr, &QThread::finished, this, &EventLoop::deleteLater); @@ -219,4 +219,22 @@ void EventLoop::exec() names.removeFirst(); } + + // pick the latest image from the live stream and copy that to the live root directory + // as a thumbnail. + + names = lsDirsInDir(shared->buffPath + "/img"); + + if (names.size() >= 3) + { + auto lastImgDir = shared->buffPath + "/img/" + names[names.size() - 3]; + auto imgList = lsFilesInDir(lastImgDir); + + if (!imgList.isEmpty()) + { + auto thumbnail = lastImgDir + "/" + imgList.last(); + + QFile::copy(thumbnail, shared->buffPath + "/thumb." + QFileInfo(thumbnail).suffix()); + } + } }