Browse Source

优化

master
blankk 2 years ago
parent
commit
b531d72178
  1. 13
      ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java

13
ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java

@ -5,6 +5,7 @@ import com.ruoyi.code.camera.domain.Camera; @@ -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 { @@ -29,19 +30,12 @@ public class RtspScreenshotTask {
private ICameraBrandService iCameraBrandService;
@Scheduled(cron = "0 0/5 * * * ?")
// @Scheduled(cron = "0/5 * * * * ?")
public void rtspScreenshot(){
List<String> 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<Camera> 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 { @@ -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) {

Loading…
Cancel
Save