检查、等待ffmpeg截图完成在返回请求结果
This commit is contained in:
parent
fff0345462
commit
11820db3e4
|
|
@ -13,6 +13,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "jsoncpp/json.h"
|
#include "jsoncpp/json.h"
|
||||||
#include "Util/util.h"
|
#include "Util/util.h"
|
||||||
#include "Util/logger.h"
|
#include "Util/logger.h"
|
||||||
|
|
@ -873,7 +874,25 @@ void installWebApi() {
|
||||||
//生成截图失败,可能残留空文件
|
//生成截图失败,可能残留空文件
|
||||||
File::delete_file(snap_path.data());
|
File::delete_file(snap_path.data());
|
||||||
}
|
}
|
||||||
|
struct stat buf;
|
||||||
|
clock_t delayStart = clock();
|
||||||
|
clock_t timeoutStart = clock();
|
||||||
|
long snapFileSize = 0;
|
||||||
|
while (clock() < timeoutStart + 4 * CLOCKS_PER_SEC) {
|
||||||
|
if (clock() < delayStart + 0.5 * CLOCKS_PER_SEC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
delayStart = clock();
|
||||||
|
stat(snap_path.data(), &buf);
|
||||||
|
if (buf.st_size >0) {
|
||||||
|
if (buf.st_size == snapFileSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snapFileSize = buf.st_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
StrCaseMap headerOut;
|
StrCaseMap headerOut;
|
||||||
headerOut["Content-Type"] = HttpFileManager::getContentType(".jpeg");
|
headerOut["Content-Type"] = HttpFileManager::getContentType(".jpeg");
|
||||||
invoker.responseFile(headerIn, headerOut, snap_path);
|
invoker.responseFile(headerIn, headerOut, snap_path);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue