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