v2.0.t9
Event VODs are still not playing back correctly. Trying mp4 format instead of hls.
This commit is contained in:
parent
baa69da2cd
commit
061c2571b4
|
@ -134,23 +134,18 @@ void cleanupStream(const string &plsPath)
|
|||
|
||||
void enforceMaxEvents(shared_t *share)
|
||||
{
|
||||
auto names = lsFilesInDir(".", ".m3u8");
|
||||
auto names = lsFilesInDir(".", ".mp4");
|
||||
|
||||
while (names.size() > share->maxEvents)
|
||||
{
|
||||
if (names[0] != "stream.m3u8")
|
||||
{
|
||||
// removes the playlist file extension.
|
||||
auto nameOnly = names[0].substr(0, names[0].size() - 5);
|
||||
auto imgFile = nameOnly + ".jpg";
|
||||
auto webFile = nameOnly + ".html";
|
||||
// removes the playlist file extension.
|
||||
auto nameOnly = names[0].substr(0, names[0].size() - 4);
|
||||
auto imgFile = nameOnly + ".jpg";
|
||||
auto webFile = nameOnly + ".html";
|
||||
|
||||
cleanupStream(names[0]);
|
||||
remove(names[0]);
|
||||
|
||||
if (exists(imgFile)) remove(imgFile);
|
||||
if (exists(webFile)) remove(webFile);
|
||||
}
|
||||
if (exists(names[0])) remove(names[0]);
|
||||
if (exists(imgFile)) remove(imgFile);
|
||||
if (exists(webFile)) remove(webFile);
|
||||
|
||||
names.erase(names.begin());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ using namespace std;
|
|||
using namespace std::filesystem;
|
||||
using namespace std::chrono;
|
||||
|
||||
#define APP_VER "2.0.t8"
|
||||
#define APP_VER "2.0.t9"
|
||||
#define APP_NAME "Motion Watch"
|
||||
#define REC_LOG_NAME "rec_log_lines.html"
|
||||
#define DET_LOG_NAME "det_log_lines.html"
|
||||
|
@ -47,10 +47,7 @@ using namespace std::chrono;
|
|||
struct pls_t
|
||||
{
|
||||
string evName;
|
||||
string dstPath;
|
||||
vector<string> srcPaths;
|
||||
vector<string> dstPaths;
|
||||
vector<string> extINFs;
|
||||
uint64_t createTime;
|
||||
Mat thumbnail;
|
||||
};
|
||||
|
|
|
@ -43,8 +43,8 @@ void eventLoop(shared_t *share)
|
|||
|
||||
try
|
||||
{
|
||||
wrOutm3u8(event, share);
|
||||
genHTMLvid(evName);
|
||||
wrOutVod(event, share);
|
||||
genHTMLvod(evName);
|
||||
|
||||
if (!exists(evName + ".jpg"))
|
||||
{
|
||||
|
|
|
@ -16,7 +16,6 @@ void detectMoInStream(const string &bufPath, shared_t *share)
|
|||
{
|
||||
ifstream fileIn(bufPath);
|
||||
string tsPath;
|
||||
string extINF;
|
||||
Mat thumbnail;
|
||||
|
||||
auto clipPathFilter = genTimeStr("VIDEO_TS/live/%Y/%j/%H/");
|
||||
|
@ -27,13 +26,9 @@ void detectMoInStream(const string &bufPath, shared_t *share)
|
|||
{
|
||||
tsPath = line;
|
||||
}
|
||||
else if (line.starts_with("#EXTINF"))
|
||||
{
|
||||
extINF = line;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tsPath.empty() && !extINF.empty())
|
||||
if (!tsPath.empty())
|
||||
{
|
||||
if (moDetect(tsPath, thumbnail, share))
|
||||
{
|
||||
|
@ -42,16 +37,12 @@ void detectMoInStream(const string &bufPath, shared_t *share)
|
|||
if (share->recList.find(eventName) != share->recList.end())
|
||||
{
|
||||
share->recList[eventName].srcPaths.push_back(tsPath);
|
||||
share->recList[eventName].dstPaths.push_back(genEventPath(tsPath));
|
||||
share->recList[eventName].extINFs.push_back(extINF);
|
||||
}
|
||||
else
|
||||
{
|
||||
pls_t event;
|
||||
|
||||
event.srcPaths.push_back(tsPath);
|
||||
event.dstPaths.push_back(genEventPath(tsPath));
|
||||
event.extINFs.push_back(extINF);
|
||||
|
||||
event.createTime = genEpoch();
|
||||
event.thumbnail = thumbnail.clone();
|
||||
|
@ -136,32 +127,19 @@ bool moDetect(const string &buffFile, Mat &vidThumb, shared_t *share)
|
|||
return mod;
|
||||
}
|
||||
|
||||
void wrOutm3u8(const pls_t &event, shared_t *share)
|
||||
void wrOutVod(const pls_t &event, shared_t *share)
|
||||
{
|
||||
auto plsFile = event.evName + ".m3u8";
|
||||
auto concat = event.evName + ".tmp";
|
||||
|
||||
ofstream file(plsFile.c_str());
|
||||
ofstream file(concat.c_str());
|
||||
|
||||
file << "#EXTM3U" << endl;
|
||||
file << "#EXT-X-VERSION:3" << endl;
|
||||
file << "#EXT-X-TARGETDURATION:10" << endl;
|
||||
file << "#EXT-X-MEDIA-SEQUENCE:0" << endl;
|
||||
file << "#EXT-X-START:TIME-OFFSET=0" << endl;
|
||||
file << "#EXT-X-PLAYLIST-TYPE:VOD" << endl;
|
||||
|
||||
for (auto i = 0; i < event.extINFs.size(); ++i)
|
||||
for (auto i = 0; i < event.srcPaths.size(); ++i)
|
||||
{
|
||||
auto src = event.srcPaths[i];
|
||||
auto dst = event.dstPaths[i];
|
||||
|
||||
createDirTree(path(dst).parent_path().string());
|
||||
copy_file(src, dst);
|
||||
|
||||
file << event.extINFs[i] << endl;
|
||||
file << dst << endl;
|
||||
file << "file '" << event.srcPaths[i] << "''" << endl;
|
||||
}
|
||||
|
||||
file << "#EXT-X-ENDLIST" << endl;
|
||||
|
||||
file.close();
|
||||
|
||||
system(string("ffmpeg -f concat -safe 0 -i " + concat + " -c copy " + event.evName + ".mp4").c_str());
|
||||
remove(concat);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
bool imgDiff(Mat &prev, Mat &next, shared_t *share);
|
||||
bool moDetect(const string &buffFile, Mat &vidThumb, shared_t *share);
|
||||
void detectMoInStream(const string &bufPath, shared_t *share);
|
||||
void wrOutm3u8(const pls_t &pls, shared_t *share);
|
||||
void wrOutVod(const pls_t &pls, shared_t *share);
|
||||
|
||||
#endif // MO_DETECT_H
|
||||
|
|
30
src/web.cpp
30
src/web.cpp
|
@ -51,7 +51,7 @@ void genHTMLul(const string &outputDir, const string &title, shared_t *share)
|
|||
htmlText += "</ul>\n";
|
||||
htmlText += "<h4>Motion Events</h4>\n";
|
||||
|
||||
genHTMLvid("stream");
|
||||
genHTMLstream("stream");
|
||||
}
|
||||
|
||||
for (auto &®Name : regNames)
|
||||
|
@ -96,7 +96,7 @@ void genHTMLul(const string &outputDir, const string &title, shared_t *share)
|
|||
file.close();
|
||||
}
|
||||
|
||||
void genHTMLvid(const string &name)
|
||||
void genHTMLstream(const string &name)
|
||||
{
|
||||
string htmlText = "<!DOCTYPE html>\n";
|
||||
|
||||
|
@ -143,6 +143,32 @@ void genHTMLvid(const string &name)
|
|||
file.close();
|
||||
}
|
||||
|
||||
void genHTMLvod(const string &name)
|
||||
{
|
||||
string htmlText = "<!DOCTYPE html>\n";
|
||||
|
||||
htmlText += "<html>\n";
|
||||
htmlText += "<head>\n";
|
||||
htmlText += "<meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\" />\n";
|
||||
htmlText += "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
|
||||
htmlText += "<meta http-equiv=\"Expires\" content=\"0\" />\n";
|
||||
htmlText += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
|
||||
htmlText += "<link rel='stylesheet' href='/theme.css'>\n";
|
||||
htmlText += "</head>\n";
|
||||
htmlText += "<body>\n";
|
||||
htmlText += "<video width=100% height=100% controls autoplay>\n";
|
||||
htmlText += " <source src='" + name + ".mp4' type='video/mp4'>\n";
|
||||
htmlText += "</video>\n";
|
||||
htmlText += "</body>\n";
|
||||
htmlText += "</html>";
|
||||
|
||||
ofstream file(string(name + ".html").c_str());
|
||||
|
||||
file << htmlText << endl;
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void genCSS(shared_t *share)
|
||||
{
|
||||
string cssText = "body {\n";
|
||||
|
|
Loading…
Reference in New Issue
Block a user