|
@@ -22,7 +22,6 @@ import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobResponse;
|
|
|
import com.aliyuncs.profile.DefaultProfile;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -32,6 +31,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -265,14 +265,14 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
|
|
|
public void loadCosCutFrame(String jobId, String videoSignature) {
|
|
|
try {
|
|
|
String resp = CosUtil.describeTaskDetail(jobId);
|
|
|
- if(StringUtils.isBlank(resp)){
|
|
|
+ if (StringUtils.isBlank(resp)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
String status = respJson.getString("Status");
|
|
|
|
|
|
- if(!"FINISH".equals(status)){
|
|
|
+ if (!"FINISH".equals(status)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -290,7 +290,7 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- for (int i=0; i< snapshotArray.size(); i++){
|
|
|
+ for (int i = 0; i < snapshotArray.size(); i++) {
|
|
|
String imagePath = snapshotArray.getString(i);
|
|
|
String urlStr = "https://" + CosUtil.bucket + ".cos.ap-chongqing.myqcloud.com" + imagePath;
|
|
|
|
|
@@ -319,4 +319,50 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void getTencentCutFrame(String materialId, Map<String, Object> coverMap) {
|
|
|
+ try {
|
|
|
+ QueryWrapper<MaterialCutFrame> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("video_signature", materialId);
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ MaterialCutFrame checkMaterialCutFrame = this.getOne(queryWrapper);
|
|
|
+ if (!Check.isNull(checkMaterialCutFrame)) {
|
|
|
+ log.info("已存推荐封面");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (Check.isNullMap(coverMap) || coverMap.size() == 1) {
|
|
|
+ log.info("腾讯云抽帧失败,code:{}", materialId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i <= 14; i++) {
|
|
|
+ String url = (String) coverMap.get(String.valueOf(i));
|
|
|
+ if(!Check.isNull(url)){
|
|
|
+ String cutFramePath = LoadFileUtil.downLoadFromUrl(url, imageUpLoadPath);
|
|
|
+ String cutFrameMd5 = LoadFileUtil.getMD5(cutFramePath);
|
|
|
+ MaterialCutFrame cutFrame = new MaterialCutFrame();
|
|
|
+ cutFrame.setSignature(cutFrameMd5);
|
|
|
+ cutFrame.setUrl(url);
|
|
|
+ cutFrame.setVideoSignature(materialId);
|
|
|
+ cutFrame.setImageIndex(i);
|
|
|
+ this.save(cutFrame);
|
|
|
+ LoadFileUtil.delFile(cutFramePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MaterialCutFrame getCutFrameByCode(String code) {
|
|
|
+ QueryWrapper<MaterialCutFrame> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("video_signature", code);
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ return this.getOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|