From ae87bf6bbddb781ff7316d032f8dc2302fb608ec Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期三, 19 十二月 2018 19:44:42 +0800
Subject: [PATCH] Merge QiaojiaoSystem Code (svn version is r3345)

---
 QiaoJiaSystem/DataManagerServer/http_configserver.cpp |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
index eee56d7..789f602 100644
--- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
+++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -2336,7 +2336,7 @@
             // sub = sub > 3000 ? sub - 3000 : 0000;
             //shijian yuejie buchang
             // sub = sub < 0 ? 0000 : sub;
-            int haomiao = sub % 1000;
+            int haomiao = (sub % 1000) > 50 ? ((sub % 1000) - 50) : 0;
             sub /= 1000;
             int m = sub;
             int shi, fen, miao;
@@ -2345,10 +2345,10 @@
                 shi = m / 3600;
                 fen = m / 60 % 60;
                 miao = m % 60;
-                sprintf(ch_time, "%02d:%02d:%02d.%03d", shi, fen, miao, haomiao);
-                cout << ch_time << endl;
-            } else printf("杈撳叆鏁板�煎お澶�");
+                sprintf(ch_time, "%02d:%02d:%02d.%02d", shi, fen, miao, haomiao / 10);
 
+            } else printf("杈撳叆鏁板�煎お澶�");
+            DBG("ch_time" << ch_time);
             std::string str_time(ch_time);
             //#todo 鎸夌収鏃堕棿鍛藉悕
             std::string str_imgName(AppUtil::getTimeString() + ".jpg");// = "test.jpg";
@@ -2360,7 +2360,7 @@
 
             if (str_time > str_tmpTime) {
                 ERR("{\"error\":\"Time error\"}" << str_time << " str_tmpTime " << str_tmpTime);
-                str_time = str_tmpTime.size() > 0 ? str_tmpTime.substr(0, str_tmpTime.rfind(".")) : str_time;
+                str_time = str_tmpTime.size() > 0 ? str_tmpTime : str_time;
 //            return "{\"error\":\"Time error\"}";
             }
 
@@ -2541,16 +2541,19 @@
                 DBG("path=" << vec[i]);
                 t_FilePath += vec[i] + ".mp4";
                 sub = t - t1;
-                find = true;
+                find = sub < getVideoTime(t_FilePath);
                 break;
             }
 
         } else {
             sub = t - t1;
-            if (t >= t1 && sub <= 3000) {
+            if (t >= t1) {
                 DBG("path=" << vec[i]);
                 t_FilePath += vec[i] + ".mp4";
-                find = true;
+
+                find = sub < getVideoTime(t_FilePath);
+
+                DBG("find:" << find);
                 break;
             }
         }
@@ -2565,6 +2568,30 @@
 
 }
 
+qint64 devHttpServer_c::getVideoTime(const std::string &videoPath) {
+    std::string cmd_getVideoFileTime(
+        " ffmpeg -i '" + videoPath + "' 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//");
+
+    std::string str_tmpTime = AppUtil::getCmdResult(cmd_getVideoFileTime);
+    DBG("str_tmpTime:" << str_tmpTime);//00:00:06.89
+    qint64 len_ms = 0;
+
+    QStringList list = QString::fromStdString(str_tmpTime).split(":");
+    if (list.size() == 3) {
+        len_ms = list[0].toInt() * 60 * 60 * 1000;
+        len_ms += list[1].toInt() * 60 * 1000;
+
+        QStringList s = list[2].split(".");
+        if (s.size() == 2) {
+            len_ms += s[0].toInt() * 1000;
+            len_ms += s[1].toInt() * 10;
+        }
+
+    }
+    DBG("len_ms:" << len_ms);
+    return len_ms;
+}
+
 std::vector<std::string> devHttpServer_c::forEachFile(const std::string &dir_name) {
     std::vector<std::string> v;
     auto dir = opendir(dir_name.data());

--
Gitblit v1.8.0