提交 df95c0d5 authored 作者: blu's avatar blu

revise evmlmotion

上级 63b300cd
...@@ -21,6 +21,7 @@ update: 2019/09/10 ...@@ -21,6 +21,7 @@ update: 2019/09/10
#include <future> #include <future>
#include <vector> #include <vector>
#include <queue> #include <queue>
#include <atomic>
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
...@@ -85,7 +86,7 @@ private: ...@@ -85,7 +86,7 @@ private:
bool gotFormat = false; bool gotFormat = false;
long long packetTs = 0; long long packetTs = 0;
long long packetTsDelta = 0; long long packetTsDelta = 0;
int pps = 0;
// //
int handleCloudMsg(vector<vector<uint8_t> > v) int handleCloudMsg(vector<vector<uint8_t> > v)
...@@ -482,7 +483,16 @@ private: ...@@ -482,7 +483,16 @@ private:
pFrame->coded_picture_number pFrame->coded_picture_number
); );
// string name = urlOut + "/"+ to_string(chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count()) + ".pgm"; // string name = urlOut + "/"+ to_string(chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count()) + ".pgm";
// TODO: dynamic pps adapting
if(this->pps < this->detPara.fpsProc) {
if(this->pps != 0) {
spdlog::info("evmlmotion {} pps {} is below {}, skip processing", this->selfId, this->pps, this->detPara.fpsProc);
}
detectMotion(pCodecContext->pix_fmt, pFrame, false);
}else{
detectMotion(pCodecContext->pix_fmt, pFrame, detect); detectMotion(pCodecContext->pix_fmt, pFrame, detect);
}
break; break;
} }
} }
...@@ -724,8 +734,10 @@ protected: ...@@ -724,8 +734,10 @@ protected:
spdlog::error("evmlmotion {} failed to allocated memory for AVFrame", selfId); spdlog::error("evmlmotion {} failed to allocated memory for AVFrame", selfId);
exit(1); exit(1);
} }
while(true) {
auto start = chrono::system_clock::now(); auto start = chrono::system_clock::now();
auto pktCntLast = pktCnt;
while(true) {
if(checkStop() == true) { if(checkStop() == true) {
bStopSig = true; bStopSig = true;
break; break;
...@@ -757,7 +769,7 @@ protected: ...@@ -757,7 +769,7 @@ protected:
if (packet.stream_index == streamIdx) { if (packet.stream_index == streamIdx) {
spdlog::debug("AVPacket.pts {}", packet.pts); spdlog::debug("AVPacket.pts {}", packet.pts);
if(pktCnt < NUM_PKT_IGNORE && gFirst) { if(pktCnt < NUM_PKT_IGNORE && gFirst) { // protecting against overflow
ret = decode_packet(false, &packet, pCodecCtx, pFrame); ret = decode_packet(false, &packet, pCodecCtx, pFrame);
} }
else { else {
...@@ -770,6 +782,14 @@ protected: ...@@ -770,6 +782,14 @@ protected:
if (ret < 0) { if (ret < 0) {
spdlog::error("evmlmotion error muxing packet"); spdlog::error("evmlmotion error muxing packet");
} }
if((pktCnt - pktCntLast ) == 180) {
auto delta = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now() - start).count();
this->pps = int(180/delta);
spdlog::info("evmlmotion {} metering: 180 packet in {}s, pps: {}", selfId, delta, pps);
pktCntLast = pktCnt;
start = chrono::system_clock::now();
}
} }
av_frame_free(&pFrame); av_frame_free(&pFrame);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论