瀏覽代碼

覆盖代码找回

yumeng 5 年之前
父節點
當前提交
8a4e42ea31

+ 10 - 39
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -64,10 +64,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     @Resource
     private IMaterialCutFrameService materialCutFrameService;
 
-    @Value("${oss.replace.replace-value}")
-    private String replaceValue;
-    @Value("${oss.replace.replace-old-value}")
-    private String replaceOldValue;
+
     @Value("${oss.replace.download}")
     private String downloadUrl;
 
@@ -77,33 +74,34 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         MaterialInfo materialInfo = this.getById(materialId);
         String path = materialInfo.getUrl().substring(materialInfo.getUrl().indexOf("/", 10) + 1, materialInfo.getUrl().length());
         String taskId = videoWatermarkHandle(path, tentcentWatermarkTemplate.getTemplateId());
-        DescribeTaskDetailResponse taskDetailResponse=null;
-        for(int i=0;i<10;i++){
+        DescribeTaskDetailResponse taskDetailResponse = null;
+        for (int i = 0; i < 10; i++) {
             try {
                 Thread.sleep(2000);
             } catch (InterruptedException e) {
                 log.error(e.getMessage());
             }
             taskDetailResponse = getTaskDetailResponse(taskId);
-            if(taskDetailResponse.getStatus().equals("FINISH")){
+            if (taskDetailResponse.getStatus().equals("FINISH")) {
                 break;
             }
         }
-        if(taskDetailResponse.getStatus().equals("FINISH")){
-            String videoUrl=taskDetailResponse.getWorkflowTask().getMediaProcessResultSet()[0].getTranscodeTask().getOutput().getPath();
+        if (taskDetailResponse.getStatus().equals("FINISH")) {
+            String videoUrl = taskDetailResponse.getWorkflowTask().getMediaProcessResultSet()[0].getTranscodeTask().getOutput().getPath();
             VideoWatermarkTask videoWatermarkTask = new VideoWatermarkTask();
-            videoWatermarkTask.setVideoUrl(CosConstant.COS_MEDIA_URL_PREFIX+videoUrl);
+            videoWatermarkTask.setVideoUrl(CosConstant.COS_MEDIA_URL_PREFIX + videoUrl);
             videoWatermarkTask.setVideoId(materialId);
             videoWatermarkTask.setJobId(taskId);
             videoWatermarkTask.setUserId(userId);
             videoWatermarkTask.setStatus(taskDetailResponse.getStatus());
             videoWatermarkTaskService.save(videoWatermarkTask);
-            materialInfo.setWatermarkUrl(CosConstant.COS_MEDIA_URL_PREFIX+videoUrl);
+            materialInfo.setWatermarkUrl(CosConstant.COS_MEDIA_URL_PREFIX + videoUrl);
             materialInfo.setWatermarkCode(taskId);
             this.updateById(materialInfo);
         }
 
     }
+
     @Override
     public MaterialInfo getMaterialInfoByCodeAndProjectId(String code, Long projectId) {
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
@@ -336,22 +334,18 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         uploadExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                /*try {*/
                 log.info("获取素材基本信息,code:{}", materialInfo.getCode());
                 if (!Check.isNull(materialInfo)) {
                     long l = System.currentTimeMillis();
-                    String videoUrl = materialInfo.getUrl();
-                    String url = videoUrl.replace(replaceOldValue, replaceValue);
+                    String url = materialInfo.getUrl();
                     log.info("replaceUrl:{}", url);
                     String localUrl = null;
                     it.sauronsoftware.jave.MultimediaInfo m = null;
                     FileInputStream fis = null;
                     try {
                         localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
-
                         File file = new File(localUrl);
                         it.sauronsoftware.jave.Encoder encoder = new Encoder();
-                        /*try {*/
                         m = encoder.getInfo(file);
                         long duration = m.getDuration();
                         long secondDuration = duration / 1000;
@@ -383,18 +377,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                         if (insert > 0) {
                             log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
                         }
-                        Thread thread = new Thread() {
-                            @Override
-                            public void run() {
-                                try {
-                                    log.info("开始抽帧");
-                                    materialCutFrameService.getCutFrame(videoUrl, materialInfo.getCode(), secondDuration, height, width);
-                                } catch (Exception e) {
-                                    e.printStackTrace();
-                                }
-                            }
-                        };
-                        thread.start();
                     } catch (FileNotFoundException e) {
                         e.printStackTrace();
                     } catch (IOException e) {
@@ -411,18 +393,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                             e.printStackTrace();
                         }
                     }
-
-                    /* */
-
-                       /* } catch (Exception e) {
-                            e.printStackTrace();
-                        } finally {
-                            file.delete();
-                        }*/
                 }
-                /*} catch (Exception e) {
-                    e.printStackTrace();
-                }*/
             }