-fixed the ffmpmeg cmd line formatting so it stops rewirting into
 the same video file.
This commit is contained in:
zii 2024-10-09 15:48:29 -04:00
parent 69bb706b6b
commit baa6c0f217
3 changed files with 25 additions and 14 deletions

View File

@ -32,7 +32,7 @@
using namespace std; using namespace std;
#define APP_VERSION "3.6.t4" #define APP_VERSION "3.6.t5"
#define APP_NAME "JustMotion" #define APP_NAME "JustMotion"
#define APP_TARGET "jmotion" #define APP_TARGET "jmotion"
#define DATETIME_FMT "yyyyMMddhhmmss" #define DATETIME_FMT "yyyyMMddhhmmss"

View File

@ -52,24 +52,36 @@ void RecordLoop::init()
restart(); restart();
} }
QString RecordLoop::camCmdFromConf() QStringList RecordLoop::camCmdFromConf()
{ {
auto ret = "ffmpeg -hide_banner -y -i '" + shared->recordUri + "' -strftime 1 -strftime_mkdir 1 "; QStringList ret;
ret.append("ffmpeg"); ret.append("-hide_banner"); ret.append("-y"); ret.append("-i");
ret.append(shared->recordUri);
if (shared->recordUri.contains("rtsp")) if (shared->recordUri.contains("rtsp"))
{ {
ret += "-rtsp_transport udp "; ret.append("-rtsp_transport");
ret.append("udp");
} }
if (shared->vidCodec != "copy") if (shared->vidCodec != "copy")
{ {
ret += "-vf fps=" + QString::number(shared->recFps) + ",scale=" + shared->recScale + " "; ret.append("-vf");
ret.append("fps=" + QString::number(shared->recFps) + ",scale=" + shared->recScale);
} }
ret += "-vcodec " + shared->vidCodec + " "; ret.append("-vcodec"); ret.append(shared->vidCodec);
ret += "-acodec " + shared->audCodec + " "; ret.append("-acodec"); ret.append(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/%014d.mkv" + shared->streamExt; ret.append("-reset_timestamps"); ret.append("1");
ret.append("-sc_threshold"); ret.append("0");
ret.append("-g"); ret.append("2");
ret.append("-force_key_frames"); ret.append("expr:gte(t, n_forced * 2)");
ret.append("-segment_time"); ret.append("2");
ret.append("-f"); ret.append("segment");
ret.append(shared->buffPath + "/live/%014d" + shared->streamExt);
return ret; return ret;
} }
@ -114,10 +126,9 @@ void RecordLoop::restart()
waitForFinished(); waitForFinished();
} }
auto cmdLine = camCmdFromConf(); auto args = camCmdFromConf();
auto args = parseArgs(cmdLine.toUtf8(), -1);
qInfo() << "start recording command: " << cmdLine; qInfo() << "start recording command: " << args.join(' ');
if (args.isEmpty()) if (args.isEmpty())
{ {

View File

@ -31,8 +31,8 @@ private:
QTimer *seedtimer; QTimer *seedtimer;
QTimer *checkTimer; QTimer *checkTimer;
quint64 getLatestSeed(); quint64 getLatestSeed();
QString camCmdFromConf(); QStringList camCmdFromConf();
public slots: public slots: