修正打包jar后截图路径,优化截图Timeout参数

This commit is contained in:
lawrencehj 2021-06-23 15:54:43 +08:00
parent 93e6c38c1e
commit a24b17ed3c

View File

@ -96,15 +96,16 @@ public class PlayServiceImpl implements IPlayService {
try { try {
String classPath = ResourceUtils.getURL("classpath:").getPath(); String classPath = ResourceUtils.getURL("classpath:").getPath();
// System.out.println(classPath); // System.out.println(classPath);
String path = classPath + "static/static/snap/"; // 兼容打包为jar的class路径
if(classPath.contains("jar")) { if(classPath.contains("jar")) {
classPath = classPath.substring(0, classPath.lastIndexOf(".")); classPath = classPath.substring(0, classPath.lastIndexOf("."));
classPath = classPath.substring(0, classPath.lastIndexOf("/")); classPath = classPath.substring(0, classPath.lastIndexOf("/") + 1);
path = classPath + "/snap/";
} }
if (path.startsWith("file:")) { if (classPath.startsWith("file:")) {
path = path.substring(path.indexOf(":") + 1, path.length()); classPath = classPath.substring(classPath.indexOf(":") + 1, classPath.length());
} }
String path = classPath + "static/static/snap/";
// 兼容Windows系统路径去除前面的/
if(System.getProperty("os.name").contains("indows")) { if(System.getProperty("os.name").contains("indows")) {
path = path.substring(1, path.length()); path = path.substring(1, path.length());
} }
@ -116,7 +117,7 @@ public class PlayServiceImpl implements IPlayService {
StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData(); StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
String flvUrl = streamInfoForSuccess.getFlv(); String flvUrl = streamInfoForSuccess.getFlv();
// 请求截图 // 请求截图
zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName); zlmresTfulUtils.getSnap(flvUrl, 15, 1, path, fileName);
} }
} }
System.out.println(path); System.out.println(path);