派生自 development/c++

pansen
2018-12-19 ae87bf6bbddb781ff7316d032f8dc2302fb608ec
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());