Browse Source

增加打水印接口

xuzuoyun 5 năm trước cách đây
mục cha
commit
88ccb34964

+ 12 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -12,9 +12,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -66,8 +68,16 @@ public class MaterialInfoController {
         return materialInfoService.getDetail(materialId);
 
     }
-
-
+    @PostMapping("watermark")
+    public Result<Object> watermarkVideo(@RequestParam(name = "id")String id,@RequestParam(name = "watermarketTemplateId")Integer watermarketTemplateId){
+        Result<Object> result = new Result<>();
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        materialInfoService.watermarkVideo(id,watermarketTemplateId,sysUser.getId());
+        result.setCode(200);
+        result.setSuccess(true);
+        result.setMessage("水印合成任务执行成功,请稍后查看");
+        return result;
+    }
     /**
      * 分页列表查询
      *
@@ -77,8 +87,6 @@ public class MaterialInfoController {
      * @param req
      * @return
      */
-
-
     @AutoLog(value = "素材信息-分页列表查询")
     @ApiOperation(value = "素材信息-分页列表查询", notes = "素材信息-分页列表查询")
     @GetMapping(value = "/list")

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -54,7 +54,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         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 path = materialInfo.getUrl().substring(materialInfo.getUrl().indexOf("/",10)+1,materialInfo.getUrl().length());
+        String jobId = mpsUtils.videoWaterMark(path,videoWatermarkTemplate.getTemplatePath(),videoWatermarkTemplate.getTemplateId(),videoWatermarkTemplate.getHeight());
         QueryJobListResponse.Job job = mpsUtils.getJobStatus(jobId);
         VideoWatermarkTask videoWatermarkTask = new VideoWatermarkTask();
         videoWatermarkTask.setJobId(jobId);

+ 2 - 2
module-common/src/main/java/cn/com/ctop/common/module/utils/MpsUtils.java

@@ -276,7 +276,7 @@ public class MpsUtils {
         SubmitJobsRequest request = new SubmitJobsRequest();
         JSONObject videoWatermarkInput = new JSONObject();
         videoWatermarkInput.put("Location", ossLocation);
-        videoWatermarkInput.put("Bucket", ossBucket);
+        videoWatermarkInput.put("Bucket", "ctop-media");
         try {
             videoWatermarkInput.put("Object", URLEncoder.encode(videoPath, "utf-8"));
         } catch (UnsupportedEncodingException e) {
@@ -305,7 +305,7 @@ public class MpsUtils {
         JSONArray outputs = new JSONArray();
         outputs.add(output);
         request.setOutputs(outputs.toJSONString());
-        request.setOutputBucket(ossBucket);
+        request.setOutputBucket("ctop-media");
         request.setOutputLocation(ossLocation);
         // PipelineId
         request.setPipelineId(pipelineId);