From 7ba06ab92b08d324b384c1fec6bc8c367652400b Mon Sep 17 00:00:00 2001 From: zii Date: Wed, 9 Oct 2024 13:44:25 -0400 Subject: [PATCH] v3.6.t3 -fixed some more issues with the increment naming. --- src/common.h | 2 +- src/detect_loop.cpp | 6 ++++-- src/record_loop.cpp | 32 +++++++++++++++++++++----------- src/record_loop.h | 3 +++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/common.h b/src/common.h index d4da041..8f5e8f4 100644 --- a/src/common.h +++ b/src/common.h @@ -32,7 +32,7 @@ using namespace std; -#define APP_VERSION "3.6.t2" +#define APP_VERSION "3.6.t3" #define APP_NAME "JustMotion" #define APP_TARGET "jmotion" #define DATETIME_FMT "yyyyMMddhhmmss" diff --git a/src/detect_loop.cpp b/src/detect_loop.cpp index 63c5927..bf3fd18 100644 --- a/src/detect_loop.cpp +++ b/src/detect_loop.cpp @@ -51,13 +51,15 @@ void DetectLoop::reset() void DetectLoop::preExec() { - vidAPath = shared->buffPath + "/live/" + QString::number(shared->seed - 2).leftJustified(21, '0') + shared->streamExt; - vidBPath = shared->buffPath + "/live/" + QString::number(shared->seed - 1).leftJustified(21, '0') + shared->streamExt; + vidAPath = shared->buffPath + "/live/" + QString::number(shared->seed - 1).rightJustified(20, '0') + shared->streamExt; + vidBPath = shared->buffPath + "/live/" + QString::number(shared->seed - 2).rightJustified(20, '0') + shared->streamExt; eTimer.start(); if (QFileInfo::exists(vidAPath) && QFileInfo::exists(vidBPath)) { + shared->seed += 1; + exec(); } } diff --git a/src/record_loop.cpp b/src/record_loop.cpp index 071fb6a..225c24e 100644 --- a/src/record_loop.cpp +++ b/src/record_loop.cpp @@ -15,9 +15,10 @@ RecordLoop::RecordLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : QProcess(parent) { checkTimer = 0; + seedtimer = 0; shared = sharedRes; - sharedRes->seed = 0; + sharedRes->seed = 3; connect(thr, &QThread::started, this, &RecordLoop::init); connect(thr, &QThread::finished, this, &RecordLoop::deleteLater); @@ -38,11 +39,14 @@ RecordLoop::~RecordLoop() void RecordLoop::init() { checkTimer = new QTimer(this); + seedtimer = new QTimer(this); connect(checkTimer, &QTimer::timeout, this, &RecordLoop::restart); + connect(seedtimer, &QTimer::timeout, this, &RecordLoop::checkSeed); checkTimer->setSingleShot(true); checkTimer->setInterval(3000); + seedtimer->setInterval(1000); setupBuffDir(shared->buffPath); restart(); @@ -57,28 +61,34 @@ QString RecordLoop::camCmdFromConf() ret += "-rtsp_transport udp "; } - if (shared->seed == 18446744073709551615ULL) - { - setupBuffDir(shared->buffPath, true); - - shared->seed = 0; - } - if (shared->vidCodec != "copy") { ret += "-vf fps=" + QString::number(shared->recFps) + ",scale=" + shared->recScale + " "; } - shared->seed += 1; - ret += "-vcodec " + shared->vidCodec + " "; ret += "-acodec " + shared->audCodec + " "; ret += "-reset_timestamps 1 -sc_threshold 0 -g 2 -force_key_frames 'expr:gte(t, n_forced * 2)' -segment_time 2 -f segment "; - ret += shared->buffPath + "/live/" + QString::number(shared->seed).leftJustified(21, '0') + shared->streamExt; + ret += shared->buffPath + "/live/%020d" + shared->streamExt; return ret; } +void RecordLoop::checkSeed() +{ + if (shared->seed >= 10000000000000000000ULL) + { + terminate(); + waitForFinished(); + + setupBuffDir(shared->buffPath, true); + + shared->seed = 3; + + restart(); + } +} + QString RecordLoop::statusLine() { if (state() == QProcess::Running) diff --git a/src/record_loop.h b/src/record_loop.h index 494a779..d3f167a 100644 --- a/src/record_loop.h +++ b/src/record_loop.h @@ -22,13 +22,16 @@ class RecordLoop : public QProcess private slots: void init(); + void checkSeed(); void resetTime(); private: shared_t *shared; + QTimer *seedtimer; QTimer *checkTimer; + quint64 getLatestSeed(); QString camCmdFromConf(); public slots: