|
@@ -32,7 +32,6 @@ import java.math.RoundingMode;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Iterator;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -96,18 +95,18 @@ public class VideoService {
|
|
|
//3 生成 xosc 文件
|
|
|
String xoscPath = generateXosc(rootDirectoryPathOfLinux, xodrPathOfLinux, osgbPathOfLinux, projectId, projectType);
|
|
|
// 启动虚拟窗口
|
|
|
- log.info("生成xosc文件路径-----"+xoscPath);
|
|
|
+ log.info("生成xosc文件路径-----" + xoscPath);
|
|
|
//4 生成图片
|
|
|
String pictureDirectoryPath = rootDirectoryPathOfLinux + "picture";
|
|
|
FileUtil.createDirectory(pictureDirectoryPath);
|
|
|
String esminiCommandTemp = esminiCommand + " " + xoscPath + " " + pictureDirectoryPath + "/screenshot " + StringUtil.doubleToString(Double.parseDouble(maxSimulationTime), 2);
|
|
|
LinuxUtil.execute2(XvfbCommand, esminiCommandTemp);
|
|
|
// String esminiResult = LinuxUtil.execute(esminiCommandTemp);
|
|
|
- int num=14;
|
|
|
- for (int i=0;i<num;i++ ) {
|
|
|
- String remove="rm -f "+ pictureDirectoryPath + "/screenshot_0000"+i+".tga";
|
|
|
- log.info("删除图片=="+remove);
|
|
|
- LinuxUtil.execute( remove);
|
|
|
+ int num = 14;
|
|
|
+ for (int i = 0; i < num; i++) {
|
|
|
+ String remove = "rm -f " + pictureDirectoryPath + "/screenshot_0000" + i + ".tga";
|
|
|
+ log.info("删除图片==" + remove);
|
|
|
+ LinuxUtil.execute(remove);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -118,7 +117,7 @@ public class VideoService {
|
|
|
|
|
|
String execute = LinuxUtil.execute("ffmpeg"
|
|
|
+ " -f image2 -framerate 30 "
|
|
|
- + "-start_number "+num
|
|
|
+ + "-start_number " + num
|
|
|
+ " -i " + pictureDirectoryPath + "/screenshot_%05d.tga"
|
|
|
+ " -c:v libx264 -vf format=yuv420p -crf 20 "
|
|
|
+ videoTargetPathOfLinux
|
|
@@ -127,9 +126,16 @@ public class VideoService {
|
|
|
MinioUtil.uploadFromFile(minioClient, videoTargetPathOfLinux, bucketName, videoTargetPathOfMinio);
|
|
|
log.info("上传成功:" + videoTargetPathOfMinio);
|
|
|
//删除生成的临时文件
|
|
|
- String removeAll="rm -rf "+ pictureDirectoryPath ;
|
|
|
- log.info("删除全部图片=="+removeAll);
|
|
|
- LinuxUtil.execute( removeAll);
|
|
|
+ String removeAll = "rm -rf " + pictureDirectoryPath;
|
|
|
+ log.info("删除全部图片==" + removeAll);
|
|
|
+ FileUtil.rm(xodrPathOfLinux);
|
|
|
+ FileUtil.rm(osgbPathOfLinux);
|
|
|
+ FileUtil.rm(csv1PathOfLinux);
|
|
|
+ FileUtil.rm(csv2PathOfLinux);
|
|
|
+
|
|
|
+ //* -------------------------------- 删除临时文件 --------------------------------
|
|
|
+ LinuxUtil.execute(removeAll);
|
|
|
+
|
|
|
return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
}
|
|
|
|
|
@@ -155,7 +161,7 @@ public class VideoService {
|
|
|
String newXoscPath = oldXoscPath.replace(oldXoscName, newXoscName);
|
|
|
//获取三维自车对象
|
|
|
VehicleTypePO po = vehicleById(projectId, projectType);
|
|
|
- log.info("修改 xosc 文件----=="+po.getModel3d());
|
|
|
+ log.info("修改 xosc 文件----==" + po.getModel3d());
|
|
|
|
|
|
//1 创建Reader对象
|
|
|
SAXReader reader = new SAXReader();
|
|
@@ -184,11 +190,11 @@ public class VideoService {
|
|
|
Attribute vehicleCategory = node3.attribute("vehicleCategory");
|
|
|
vehicleCategory.setText(po.getVehicleCategory());
|
|
|
//node3.addAttribute("model3d", po.getModel3d());//自车渲染
|
|
|
- if(null==po.getModel3d()||po.getModel3d().equals("")){
|
|
|
+ if (null == po.getModel3d() || po.getModel3d().equals("")) {
|
|
|
node3.addAttribute("model3d", "/root/disk1/simulation-cloud/esmini/resources/models/car_red.osgb");//自车渲染
|
|
|
- }else{
|
|
|
- log.info(" 车辆类型为 为:"+po.getVehicleCategory()+" 渲染文件为:" + po.getModel3d());
|
|
|
- node3.addAttribute("model3d",po.getModel3d());
|
|
|
+ } else {
|
|
|
+ log.info(" 车辆类型为 为:" + po.getVehicleCategory() + " 渲染文件为:" + po.getModel3d());
|
|
|
+ node3.addAttribute("model3d", po.getModel3d());
|
|
|
}
|
|
|
Iterator<Element> iterator4 = node3.elementIterator();
|
|
|
while (iterator4.hasNext()) {
|
|
@@ -343,7 +349,7 @@ public class VideoService {
|
|
|
String car = vehicleType.substring( vehicleType.indexOf(",")+1,vehicleType.lastIndexOf(","));
|
|
|
log.info("VideoService--vehicleById 车辆类型为:" + car);
|
|
|
*/
|
|
|
- String car=vehicleInfo.getModelLabel();
|
|
|
+ String car = vehicleInfo.getModelLabel();
|
|
|
/*String carPath=dictMapper.getCarPath(car);
|
|
|
if(null!=carPath&&!carPath.equals("")){
|
|
|
po.setVehicleCategory(car);
|