From abe1698601c8d19c1a9fbceccf45c339313173c2 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 9 May 2020 09:39:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=87=8D=E5=A4=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=88=AA=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 183b9ca0..e4b18a6b 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -858,12 +858,17 @@ void installWebApi() { //无截图或者截图已经过期 snap_path = StrPrinter << scan_path << time(NULL) << ".jpeg"; -#if !defined(_WIN32) - //创建文件夹 - File::create_path(snap_path.c_str(), S_IRWXO | S_IRWXG | S_IRWXU); -#else - File::create_path(snap_path.c_str(),0); -#endif + + { + //生成一个空文件,目的是顺便创建文件夹路径, + //同时防止在FFmpeg生成截图途中不停的尝试调用该api启动FFmpeg生成相同的截图 + //当然,我们可以拷贝一个"正在截图中"的图来替换这个空图,这需要开发者自己实现 + auto file = File::create_file(snap_path.data(), "wb"); + if(file){ + fclose(file); + } + } + FFmpegSnap::makeSnap(allArgs["url"],snap_path,allArgs["timeout_sec"],[invoker,headerIn,snap_path](bool success){ if(!success){ //生成截图失败,可能残留空文件