From b531d72178678154cd92f07c6eaeee18556841ed Mon Sep 17 00:00:00 2001 From: blankk <2649084208@qq.com> Date: Mon, 26 Sep 2022 15:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code/camera/scheduled/RtspScreenshotTask.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java b/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java index 233212a..c274fea 100644 --- a/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java +++ b/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java @@ -5,6 +5,7 @@ import com.ruoyi.code.camera.domain.Camera; import com.ruoyi.code.camera.domain.CameraBrand; import com.ruoyi.code.camera.service.ICameraBrandService; import com.ruoyi.code.camera.service.ICameraService; +import com.ruoyi.common.config.RuoYiConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; @@ -29,19 +30,12 @@ public class RtspScreenshotTask { private ICameraBrandService iCameraBrandService; @Scheduled(cron = "0 0/5 * * * ?") -// @Scheduled(cron = "0/5 * * * * ?") public void rtspScreenshot(){ List strList = new ArrayList<>(); - String path = "D:" + File.separator + File.separator + "upload" + File.separator; - String ip = "192.168.1.40"; - String userName = "admin"; - String pwd = "admin123"; - + String path = RuoYiConfig.getProfile() + File.separator; String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + File.separator; String currentTime = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + ".jpg"; - List list = cameraService.list(); - for (Camera camera : list) { CameraBrand cameraBrand = iCameraBrandService.getById(camera.getBrand()); String fileName = path+camera.getDevsn()+File.separator+currentDate; @@ -49,8 +43,7 @@ public class RtspScreenshotTask { if (!file.exists()) { file.mkdirs(); } - String ffmpeg = -"ffmpeg -i \"rtsp://"+userName+":"+pwd+"@"+ip+cameraBrand.getRtsp()+"\" -y -f image2 -t 0.001 \""+fileName+currentTime+"\""; + String ffmpeg = "ffmpeg -i \"rtsp://"+camera.getUsername()+":"+camera.getPassword()+"@"+camera.getIp()+cameraBrand.getRtsp()+"\" -y -f image2 -t 0.001 \""+fileName+currentTime+"\""; strList.add(ffmpeg); } for (String s : strList) {