From f93ee1a42e8c47e472332287b7350b66a6b0fa11 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 24 七月 2020 18:28:57 +0800 Subject: [PATCH] 保存触发id之后的视频作为触发视频 --- csrc/wrapper.cpp | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp index 813ddb7..4964629 100644 --- a/csrc/wrapper.cpp +++ b/csrc/wrapper.cpp @@ -56,7 +56,7 @@ ,logit_(false) ,fps_(25) ,file_finished_(false) - ,min_duration_(60) + ,min_duration_(0) { makeTheWorld(); } @@ -77,7 +77,7 @@ ,logit_(true) ,fps_(25) ,file_finished_(false) - ,min_duration_(60) + ,min_duration_(0) { makeTheWorld(); logif::CreateLogger(logfile, true); @@ -222,7 +222,7 @@ bool exist = access(input_url_.c_str(), 0) == 0; if (exist){ - wTime <<= 1; + wTime += wTime/2; file_rebootime++; } @@ -259,10 +259,10 @@ id++; //鏈湴鏂囦欢澶揩sleep涓�涓� - if (exist){ - usleep(wTime); + if (exist && in->isVideoPkt(&data->getAVPacket())){ // 璁板綍瑙g爜鐨勬枃浠舵湁澶氬皯甯� file_frame++; + usleep(wTime); } } @@ -270,15 +270,18 @@ deinit_worker(); if (exist) { // 涓夋涓�甯ч兘娌¤В鍑烘潵锛岄��鍑� - if (file_frame == 0 && file_rebootime > 3){ - file_finished_ = true; - break; + if (file_frame == 0 && file_rebootime < 3){ + logIt("libcffmpeg.so-> run %lld time, current frames %lld", file_rebootime, file_frame); + continue; } // 鏈�灏忛渶瑕佽В鍑哄灏戝抚 if (file_frame < min_duration_ * fps_){ + logIt("libcffmpeg.so-> run %lld time, current frames %lld, mind %d, fps: %d", + file_rebootime, file_frame, min_duration_, fps_); continue; } - logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld", input_url_.c_str(), file_rebootime, file_frame); + logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld, mind %d, fps: %d", + input_url_.c_str(), file_rebootime, file_frame, min_duration_, fps_); file_finished_ = true; break; } -- Gitblit v1.8.0