v3.0.t18
-ffmpeg still stalls even with tcp timeout parameters in place. added self end -t option to match the heart beat of RecLoop. doing this auto re-fresh ffmpeg every 30mins and should prevent stall. for some reason ffmpeg just can't run long term without stalling.
This commit is contained in:
parent
a493c7da5d
commit
71fc5b0bc2
|
@ -107,8 +107,9 @@ bool Loop::exec()
|
||||||
|
|
||||||
RecLoop::RecLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent)
|
RecLoop::RecLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent)
|
||||||
{
|
{
|
||||||
recProc = 0;
|
recProc = 0;
|
||||||
imgProc = 0;
|
imgProc = 0;
|
||||||
|
heartBeat = 1800;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecLoop::init()
|
void RecLoop::init()
|
||||||
|
@ -117,8 +118,8 @@ void RecLoop::init()
|
||||||
imgProc = new QProcess(this);
|
imgProc = new QProcess(this);
|
||||||
|
|
||||||
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &RecLoop::term);
|
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &RecLoop::term);
|
||||||
|
connect(recProc, &QProcess::readyReadStandardError, this, &RecLoop::rdProcErr);
|
||||||
updateCmd();
|
connect(imgProc, &QProcess::readyReadStandardError, this, &RecLoop::rdProcErr);
|
||||||
|
|
||||||
Loop::init();
|
Loop::init();
|
||||||
}
|
}
|
||||||
|
@ -141,6 +142,7 @@ void RecLoop::updateCmd()
|
||||||
recArgs << "-hls_flags" << "append_list";
|
recArgs << "-hls_flags" << "append_list";
|
||||||
recArgs << "-rtsp_transport" << "tcp";
|
recArgs << "-rtsp_transport" << "tcp";
|
||||||
recArgs << "-stimeout" << "3000";
|
recArgs << "-stimeout" << "3000";
|
||||||
|
recArgs << "-t" << QString::number(heartBeat);
|
||||||
recArgs << "stream.m3u8";
|
recArgs << "stream.m3u8";
|
||||||
|
|
||||||
imgArgs << "-hide_banner";
|
imgArgs << "-hide_banner";
|
||||||
|
@ -150,6 +152,7 @@ void RecLoop::updateCmd()
|
||||||
imgArgs << "-vf" << "fps=1,scale=320:240";
|
imgArgs << "-vf" << "fps=1,scale=320:240";
|
||||||
imgArgs << "-rtsp_transport" << "tcp";
|
imgArgs << "-rtsp_transport" << "tcp";
|
||||||
imgArgs << "-stimeout" << "3000";
|
imgArgs << "-stimeout" << "3000";
|
||||||
|
imgArgs << "-t" << QString::number(heartBeat);
|
||||||
imgArgs << "img/" + QString(STRFTIME_FMT) + ".bmp";
|
imgArgs << "img/" + QString(STRFTIME_FMT) + ".bmp";
|
||||||
|
|
||||||
recProc->setProgram("ffmpeg");
|
recProc->setProgram("ffmpeg");
|
||||||
|
@ -160,8 +163,12 @@ void RecLoop::updateCmd()
|
||||||
|
|
||||||
recLog("rec_args: " + recArgs.join(" "), shared);
|
recLog("rec_args: " + recArgs.join(" "), shared);
|
||||||
recLog("img_args: " + imgArgs.join(" "), shared);
|
recLog("img_args: " + imgArgs.join(" "), shared);
|
||||||
|
}
|
||||||
|
|
||||||
curUrl = shared->recordUrl;
|
void RecLoop::rdProcErr()
|
||||||
|
{
|
||||||
|
procError("img", imgProc);
|
||||||
|
procError("rec", recProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecLoop::term()
|
void RecLoop::term()
|
||||||
|
@ -173,17 +180,9 @@ void RecLoop::term()
|
||||||
imgProc->waitForFinished();
|
imgProc->waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecLoop::reset()
|
|
||||||
{
|
|
||||||
recLog("--rec_and_img_cmds_resetting--", shared);
|
|
||||||
|
|
||||||
term();
|
|
||||||
updateCmd();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecLoop::procError(const QString &desc, QProcess *proc)
|
void RecLoop::procError(const QString &desc, QProcess *proc)
|
||||||
{
|
{
|
||||||
if (proc->isOpen() && proc->state() == QProcess::NotRunning)
|
if (proc->isOpen() && (proc->state() != QProcess::Running))
|
||||||
{
|
{
|
||||||
auto errBlob = QString(proc->readAllStandardError());
|
auto errBlob = QString(proc->readAllStandardError());
|
||||||
auto errLines = errBlob.split('\n');
|
auto errLines = errBlob.split('\n');
|
||||||
|
@ -198,37 +197,17 @@ void RecLoop::procError(const QString &desc, QProcess *proc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecLoop::startProc(const QString &desc, QProcess *proc)
|
|
||||||
{
|
|
||||||
if (proc->state() == QProcess::NotRunning)
|
|
||||||
{
|
|
||||||
proc->start();
|
|
||||||
|
|
||||||
if (proc->waitForStarted())
|
|
||||||
{
|
|
||||||
recLog(desc + "_cmd_start: ok", shared);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
recLog(desc + "_cmd_start: fail", shared);
|
|
||||||
procError(desc, proc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RecLoop::exec()
|
bool RecLoop::exec()
|
||||||
{
|
{
|
||||||
procError("img", imgProc);
|
if ((imgProc->state() == QProcess::Running) || (recProc->state() == QProcess::Running))
|
||||||
procError("rec", recProc);
|
|
||||||
|
|
||||||
if (curUrl != shared->recordUrl)
|
|
||||||
{
|
{
|
||||||
recLog("a change in the recording URL was detected.", shared);
|
term();
|
||||||
reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startProc("img", imgProc);
|
updateCmd();
|
||||||
startProc("rec", recProc);
|
|
||||||
|
imgProc->start();
|
||||||
|
recProc->start();
|
||||||
|
|
||||||
return Loop::exec();
|
return Loop::exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,13 @@ private:
|
||||||
QString curUrl;
|
QString curUrl;
|
||||||
|
|
||||||
void updateCmd();
|
void updateCmd();
|
||||||
void reset();
|
|
||||||
void startProc(const QString &desc, QProcess *proc);
|
|
||||||
void procError(const QString &desc, QProcess *proc);
|
void procError(const QString &desc, QProcess *proc);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void term();
|
void term();
|
||||||
|
void rdProcErr();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define APP_VER "3.0.t17"
|
#define APP_VER "3.0.t18"
|
||||||
#define APP_NAME "Motion Watch"
|
#define APP_NAME "Motion Watch"
|
||||||
#define APP_BIN "mow"
|
#define APP_BIN "mow"
|
||||||
#define REC_LOG_NAME "rec_log_lines.html"
|
#define REC_LOG_NAME "rec_log_lines.html"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user