提交 57b89bae authored 作者: blu's avatar blu

upload video files

上级 fcd444f4
...@@ -505,13 +505,14 @@ protected: ...@@ -505,13 +505,14 @@ protected:
return mktime(&t); return mktime(&t);
} }
string videoFileTs2Name(long ts) { string videoFileTs2Name(long ts, bool bLog = false) {
std::time_t now = ts; std::time_t now = ts;
std::tm * ptm = std::localtime(&now); std::tm * ptm = std::localtime(&now);
char buffer[20]; char buffer[20];
// Format: Mo, 15.06.2009 20:20:00 // Format: Mo, 15.06.2009 20:20:00
std::strftime(buffer, 20, "%Y%m%d_%H%M%S", ptm); std::strftime(buffer, 20, "%Y%m%d_%H%M%S", ptm);
spdlog::info("ts: {}, fname: {}", ts, buffer); if(bLog)
spdlog::info("ts: {}, fname: {}/{}.mp4", ts, this->urlOut, buffer);
return string(buffer); return string(buffer);
} }
...@@ -693,8 +694,8 @@ protected: ...@@ -693,8 +694,8 @@ protected:
for(int i = idxS; i <= idxE; i++){ for(int i = idxS; i <= idxE; i++){
int idx = segToIdx(i); int idx = segToIdx(i);
long ts = vTsActive[idx]; long ts = vTsActive[idx];
string fname = videoFileTs2Name(ts); string fname = videoFileTs2Name(ts, true);
sf += "\t" +fname + ", " + to_string(ts) + ", " + to_string(idx) + "\n"; sf += "\n\t" + this->urlOut + "/" + fname + ".mp4, " + to_string(ts) + ", " + to_string(idx);
ret.push_back(fname); ret.push_back(fname);
} }
spdlog::info("evslicer {} event {} - {} files to upload: {}", selfId, videoFileTs2Name(tss), videoFileTs2Name(tse), sf); spdlog::info("evslicer {} event {} - {} files to upload: {}", selfId, videoFileTs2Name(tss), videoFileTs2Name(tse), sf);
...@@ -799,15 +800,19 @@ public: ...@@ -799,15 +800,19 @@ public:
}else{ }else{
vector<tuple<string, string> > params= {{"startTime", to_string(tss)},{"endTime", to_string(tse)},{"cameraId", ipcSn}, {"headOffset", to_string(offsetS)},{"tailOffset", to_string(offsetE)}}; vector<tuple<string, string> > params= {{"startTime", to_string(tss)},{"endTime", to_string(tse)},{"cameraId", ipcSn}, {"headOffset", to_string(offsetS)},{"tailOffset", to_string(offsetE)}};
vector<string> fileNames; vector<string> fileNames;
string sf;
for(auto &i: v) { for(auto &i: v) {
string fname = this->urlOut + "/" + i + ".mp4"; string fname = this->urlOut + "/" + i + ".mp4";
fileNames.push_back(fname); fileNames.push_back(fname);
sf+="\n\t" + fname;
} }
spdlog::info("evslicer {} file upload url: {}", selfId, this->videoFileServerApi); spdlog::info("evslicer {} file upload url: {}", selfId, this->videoFileServerApi);
// TODO: check result and reschedule it // TODO: check result and reschedule it
if(netutils::postFiles(std::move(this->videoFileServerApi), std::move(params), std::move(fileNames)) != 0){ if(netutils::postFiles(std::move(this->videoFileServerApi), std::move(params), std::move(fileNames)) != 0){
spdlog::error("evslicer {} failed to upload files", selfId); spdlog::error("evslicer {} failed to upload files: {}", selfId, sf);
}else{
spdlog::info("evslicer {} successfull uploaded files: {}", selfId, sf);
} }
} }
}else{ }else{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论