Browse Source

优化

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

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

@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -30,10 +29,8 @@ public class RtspScreenshotTask {
@Autowired @Autowired
private ICameraBrandService iCameraBrandService; private ICameraBrandService iCameraBrandService;
@Scheduled(fixedRate = 1000000) @Scheduled(cron = "0 0/5 * * * ?")
// @Scheduled(cron = "0 0/5 * * * ?")
public void rtspScreenshot(){ public void rtspScreenshot(){
List<String> strList = new ArrayList<>();
String path = RuoYiConfig.getProfile() + File.separator; String path = RuoYiConfig.getProfile() + File.separator;
String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + 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"; String currentTime = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + ".jpg";
@ -46,10 +43,7 @@ public class RtspScreenshotTask {
file.mkdirs(); file.mkdirs();
} }
String ffmpeg = "ffmpeg -i \"rtsp://"+camera.getUsername()+":"+camera.getPassword()+"@"+camera.getIp()+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); RuntimeUtil.execForStr(ffmpeg);
}
for (String s : strList) {
RuntimeUtil.execForStr(s);
} }
} }
} }

Loading…
Cancel
Save