From 69bb706b6b6d11afffe8dca9e437af4f223aa678 Mon Sep 17 00:00:00 2001 From: zii Date: Wed, 9 Oct 2024 14:39:11 -0400 Subject: [PATCH] v3.6.t4 -ffmpeg arbitrarily limits %020d. backed it down %014d, not sure if that is true limit. 14 was tessted to work. -added file size checking in detect loop to prevent it from processesing unfinished video clips. --- src/common.h | 2 +- src/detect_loop.cpp | 11 ++++++++--- src/record_loop.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/common.h b/src/common.h index 8f5e8f4..3009788 100644 --- a/src/common.h +++ b/src/common.h @@ -32,7 +32,7 @@ using namespace std; -#define APP_VERSION "3.6.t3" +#define APP_VERSION "3.6.t4" #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 bf3fd18..b709137 100644 --- a/src/detect_loop.cpp +++ b/src/detect_loop.cpp @@ -32,6 +32,8 @@ void DetectLoop::init() connect(pcTimer, &QTimer::timeout, this, &DetectLoop::pcBreak); connect(deTimer, &QTimer::timeout, this, &DetectLoop::preExec); + thread()->sleep(2); // delay detection kickoff by 2 seconds to allow RecLoop to buffer + pcTimer->start(shared->postSecs * 1000); deTimer->start(2000); @@ -51,12 +53,15 @@ void DetectLoop::reset() void DetectLoop::preExec() { - 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; + vidAPath = shared->buffPath + "/live/" + QString::number(shared->seed - 1).rightJustified(14, '0') + shared->streamExt; + vidBPath = shared->buffPath + "/live/" + QString::number(shared->seed - 2).rightJustified(14, '0') + shared->streamExt; eTimer.start(); - if (QFileInfo::exists(vidAPath) && QFileInfo::exists(vidBPath)) + auto vidAInfo = QFileInfo(vidAPath); + auto vidBInfo = QFileInfo(vidBPath); + + if (vidAInfo.exists() && vidAInfo.size() > 0 && vidBInfo.exists() && vidBInfo.size() > 0) { shared->seed += 1; diff --git a/src/record_loop.cpp b/src/record_loop.cpp index 225c24e..a5440cb 100644 --- a/src/record_loop.cpp +++ b/src/record_loop.cpp @@ -18,7 +18,7 @@ RecordLoop::RecordLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : QPr seedtimer = 0; shared = sharedRes; - sharedRes->seed = 3; + sharedRes->seed = 2; connect(thr, &QThread::started, this, &RecordLoop::init); connect(thr, &QThread::finished, this, &RecordLoop::deleteLater); @@ -69,21 +69,21 @@ QString RecordLoop::camCmdFromConf() 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/%020d" + shared->streamExt; + ret += shared->buffPath + "/live/%014d.mkv" + shared->streamExt; return ret; } void RecordLoop::checkSeed() { - if (shared->seed >= 10000000000000000000ULL) + if (shared->seed >= 99999999999999ULL) { terminate(); waitForFinished(); setupBuffDir(shared->buffPath, true); - shared->seed = 3; + shared->seed = 2; restart(); }