|
@@ -14,9 +14,8 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyuncs.mts.model.v20140618.QueryJobListResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
- // import it.sauronsoftware.jave.Encoder;
|
|
|
+import it.sauronsoftware.jave.Encoder;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -34,6 +33,8 @@ import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
+// import it.sauronsoftware.jave.Encoder;
|
|
|
+
|
|
|
/**
|
|
|
* 素材信息
|
|
|
*
|
|
@@ -49,12 +50,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
private IVideoWatermarkTemplateService videoWatermarkTemplateService;
|
|
|
@Autowired
|
|
|
private IVideoWatermarkTaskService videoWatermarkTaskService;
|
|
|
+
|
|
|
@Override
|
|
|
- public void watermarkVideo(String materialId,Integer videoWatermarkTemplateId,String userId){
|
|
|
+ public void watermarkVideo(String materialId, Integer videoWatermarkTemplateId, String userId) {
|
|
|
VideoWatermarkTemplate videoWatermarkTemplate = videoWatermarkTemplateService.getById(videoWatermarkTemplateId);
|
|
|
MaterialInfo materialInfo = this.getById(materialId);
|
|
|
MpsUtils mpsUtils = new MpsUtils();
|
|
|
- String jobId = mpsUtils.videoWaterMark(materialInfo.getUrl(),videoWatermarkTemplate.getTemplatePath(),videoWatermarkTemplate.getTemplateId(),videoWatermarkTemplate.getHeight());
|
|
|
+ String jobId = mpsUtils.videoWaterMark(materialInfo.getUrl(), videoWatermarkTemplate.getTemplatePath(), videoWatermarkTemplate.getTemplateId(), videoWatermarkTemplate.getHeight());
|
|
|
QueryJobListResponse.Job job = mpsUtils.getJobStatus(jobId);
|
|
|
VideoWatermarkTask videoWatermarkTask = new VideoWatermarkTask();
|
|
|
videoWatermarkTask.setJobId(jobId);
|
|
@@ -64,6 +66,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
materialInfo.setWatermarkCode(jobId);
|
|
|
this.updateById(materialInfo);
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public MaterialInfo getMaterialInfoByCode(String code) {
|
|
|
QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
|
|
@@ -165,7 +168,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // getFile(info);
|
|
|
+ getFile(info);
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
|
|
|
} catch (Exception e) {
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
|
|
@@ -269,63 +272,62 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
@Autowired
|
|
|
private MaterialParameterMapper materialParameterMapper;
|
|
|
|
|
|
- /* public void getFile(MaterialInfo materialInfo) {
|
|
|
- *//* uploadExecutorService.submit(new Runnable() {
|
|
|
+ public void getFile(MaterialInfo materialInfo) {
|
|
|
+ uploadExecutorService.submit(new Runnable() {
|
|
|
@Override
|
|
|
- public void run() {*//*
|
|
|
- try {
|
|
|
- System.err.println("开始获取素材基本信息");
|
|
|
- System.err.println(materialInfo);
|
|
|
- if (!Check.isNull(materialInfo)) {
|
|
|
- String url = materialInfo.getUrl();
|
|
|
- long l = System.currentTimeMillis();
|
|
|
- //PropertiesUtils.getValue("kuaishou_config", "video_sava_path")
|
|
|
- String localUrl = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
|
|
|
- File file = new File(localUrl);
|
|
|
- it.sauronsoftware.jave.Encoder encoder = new Encoder();
|
|
|
- *//*try {*//*
|
|
|
- it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
|
|
|
- long duration = m.getDuration();
|
|
|
- long secondDuration = duration / 1000;
|
|
|
- MaterialParameter materialParameter = new MaterialParameter();
|
|
|
- materialParameter.setMaterialId(materialInfo.getId());
|
|
|
- // 视频秒数
|
|
|
- materialParameter.setSecond(secondDuration);
|
|
|
- // 视频格式
|
|
|
- materialParameter.setFormat(m.getFormat());
|
|
|
- // 视频宽
|
|
|
- materialParameter.setWidth(String.valueOf(m.getVideo().getSize().getWidth()));
|
|
|
- // 视频高
|
|
|
- materialParameter.setHeight(String.valueOf(m.getVideo().getSize().getHeight()));
|
|
|
-
|
|
|
- FileInputStream fis = new FileInputStream(file);
|
|
|
- FileChannel fc = fis.getChannel();
|
|
|
- BigDecimal fileSize = new BigDecimal(fc.size());
|
|
|
- String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
|
|
|
- materialParameter.setSize(size);
|
|
|
-
|
|
|
- Map<String, Object> deleteMap = new HashMap<>();
|
|
|
- deleteMap.put("material_id", materialInfo.getId());
|
|
|
- materialParameterMapper.deleteByMap(deleteMap);
|
|
|
-
|
|
|
- int insert = materialParameterMapper.insert(materialParameter);
|
|
|
- if (insert > 0) {
|
|
|
- log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
|
|
|
-
|
|
|
- }
|
|
|
- System.err.println(2222222);
|
|
|
- *//* } catch (Exception e) {
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ System.err.println("开始获取素材基本信息");
|
|
|
+ System.err.println(materialInfo);
|
|
|
+ if (!Check.isNull(materialInfo)) {
|
|
|
+ String url = materialInfo.getUrl();
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ //PropertiesUtils.getValue("kuaishou_config", "video_sava_path")
|
|
|
+ String localUrl = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
|
|
|
+ File file = new File(localUrl);
|
|
|
+ it.sauronsoftware.jave.Encoder encoder = new Encoder();
|
|
|
+ try {
|
|
|
+ it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
|
|
|
+ long duration = m.getDuration();
|
|
|
+ long secondDuration = duration / 1000;
|
|
|
+ MaterialParameter materialParameter = new MaterialParameter();
|
|
|
+ materialParameter.setMaterialId(materialInfo.getId());
|
|
|
+ // 视频秒数
|
|
|
+ materialParameter.setSecond(secondDuration);
|
|
|
+ // 视频格式
|
|
|
+ materialParameter.setFormat(m.getFormat());
|
|
|
+ // 视频宽
|
|
|
+ materialParameter.setWidth(String.valueOf(m.getVideo().getSize().getWidth()));
|
|
|
+ // 视频高
|
|
|
+ materialParameter.setHeight(String.valueOf(m.getVideo().getSize().getHeight()));
|
|
|
+
|
|
|
+ FileInputStream fis = new FileInputStream(file);
|
|
|
+ FileChannel fc = fis.getChannel();
|
|
|
+ BigDecimal fileSize = new BigDecimal(fc.size());
|
|
|
+ String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
|
|
|
+ materialParameter.setSize(size);
|
|
|
+
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
+ deleteMap.put("material_id", materialInfo.getId());
|
|
|
+ materialParameterMapper.deleteByMap(deleteMap);
|
|
|
+
|
|
|
+ int insert = materialParameterMapper.insert(materialParameter);
|
|
|
+ if (insert > 0) {
|
|
|
+ log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- } *//**//*finally {
|
|
|
- file.delete();
|
|
|
- }*//*
|
|
|
+ }
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- *//* }
|
|
|
- });*//*
|
|
|
- }*/
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|