|
@@ -468,6 +468,90 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+
|
|
|
+ String a = "hahah-1002-1629271205922";
|
|
|
+ if(a.contains("-")){
|
|
|
+
|
|
|
+ String str1=a.substring(0, a.lastIndexOf("-"));
|
|
|
+ System.err.println(str1);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ String url = "https://media-1301855440.cos.ap-chongqing.myqcloud.com/video/2021-07-05/%E4%BC%98%E9%85%B7-%E8%8A%B1%E5%A5%BD%E6%9C%88%E5%8F%88%E5%9C%868-0705-1625479713948.mp4";
|
|
|
+ log.info("replaceUrl:{}", url);
|
|
|
+ String localUrl = null;
|
|
|
+ it.sauronsoftware.jave.MultimediaInfo m = null;
|
|
|
+ String downloadUrl = "D:\\test";
|
|
|
+ FileInputStream fis = null;
|
|
|
+ try {
|
|
|
+ String fileName = AesEncryptUtil.getUrlDecoderString(url.substring(url.lastIndexOf("/") + 1));
|
|
|
+ String fileNameNoEx = StringUtils.getFileNameNoEx(fileName);
|
|
|
+ System.err.println(fileNameNoEx);
|
|
|
+ System.err.println(fileName);
|
|
|
+
|
|
|
+ localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
|
+ File file = new File(localUrl);
|
|
|
+ it.sauronsoftware.jave.Encoder encoder = new Encoder();
|
|
|
+ m = encoder.getInfo(file);
|
|
|
+ System.err.println(m);
|
|
|
+ long duration = m.getDuration();
|
|
|
+ long secondDuration = duration / 1000;
|
|
|
+ MaterialParameter materialParameter = new MaterialParameter();
|
|
|
+
|
|
|
+ // 视频秒数
|
|
|
+ materialParameter.setSecond(secondDuration);
|
|
|
+ // 视频格式
|
|
|
+ materialParameter.setFormat(m.getFormat());
|
|
|
+ // 视频宽
|
|
|
+ String width = String.valueOf(m.getVideo().getSize().getWidth());
|
|
|
+ materialParameter.setWidth(width);
|
|
|
+ // 视频高
|
|
|
+ String height = String.valueOf(m.getVideo().getSize().getHeight());
|
|
|
+ materialParameter.setHeight(height);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ materialParameter.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ 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 (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (EncoderException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (fis != null) {
|
|
|
+ fis.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void setExcellent(String code, Integer excellent) {
|
|
|
MaterialInfo info = this.getMaterialInfoByCode(code);
|