|
@@ -146,7 +146,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // getFile(info);
|
|
|
|
|
|
+ getFile(info);
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
|
|
@@ -253,61 +253,60 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
private MaterialParameterMapper materialParameterMapper;
|
|
private MaterialParameterMapper materialParameterMapper;
|
|
|
|
|
|
public void getFile(MaterialInfo materialInfo) {
|
|
public void getFile(MaterialInfo materialInfo) {
|
|
- /* uploadExecutorService.submit(new Runnable() {
|
|
|
|
|
|
+ uploadExecutorService.submit(new Runnable() {
|
|
@Override
|
|
@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);
|
|
|
|
|
|
+ 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) {
|
|
/* } catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
} *//*finally {
|
|
} *//*finally {
|
|
file.delete();
|
|
file.delete();
|
|
}*/
|
|
}*/
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- /* }
|
|
|
|
- });*/
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|