Browse Source

Merge remote-tracking branch 'origin/test' into test

syh 5 years ago
parent
commit
313c3b14df

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/WatermarkVideoJob.java

@@ -35,7 +35,7 @@ public class WatermarkVideoJob implements Job {
                 MpsUtils mpsUtils = new MpsUtils();
                 QueryJobListResponse.Job job = mpsUtils.getJobStatus(videoWatermarkTask.getJobId());
                 if (job.getState().equals("TranscodeSuccess")){
-                    String url = "https://ctop-media.oss-cn-beijing.aliyuncs.com/watermark/"+DateUtils.getNowDate("yyyy-MM-dd")+"/"+job.getOutput().getOutputFile().getObject();
+                    String url = "https://ctop-media.oss-cn-beijing.aliyuncs.com/"+job.getOutput().getOutputFile().getObject();
 
                     try {
                         String localPath = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));

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

@@ -26,11 +26,12 @@ public class MpsUtils {
 //        String[] a = {"1","2","3","4","5"};
 //        combinationSelect(a,3);
 //        arrangementSelect(a,3);
-        String t = "https://ctop-part.oss-cn-beijing.aliyuncs.com/input/VIDEO_HEAD/2019-12-11/25-1576044510677.mp4";
-        int i = t.indexOf("/",10);
-        System.out.println(t.substring(i+1,t.length()-1));
+//        String t = "https://ctop-part.oss-cn-beijing.aliyuncs.com/input/VIDEO_HEAD/2019-12-11/25-1576044510677.mp4";
+//        int i = t.indexOf("/",10);
+//        System.out.println(t.substring(i+1,t.length()-1));
 
-//        MpsUtils mpsUtils = new MpsUtils();
+        MpsUtils mpsUtils = new MpsUtils();
+        mpsUtils.videoWaterMark("video/2019-12-20/20%E7%BD%91%E6%9C%8D-1576822566069.mp4","watermark/water1080-1920.png","8bcf0c98021c40fc96a95d60f55b1f10",720);
 //        List<String> list = new ArrayList<>();
 //        list.add("v1.mp4");
 //        String jobId = mpsUtils.mergeOneVideo("v1.mp4",list,"v1.mp4");
@@ -271,13 +272,20 @@ public class MpsUtils {
 
     public String videoWaterMark(String videoPath,String waterMarkPath,String watermarkTemplateId,Integer height){
         String jobId = "";
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String outputFilename = "watermark/"+sdf.format(new Date())+"/"+ UUID.randomUUID()+".mp4";
         IAcsClient client = getClient();
         String pipelineId = getPipelineId(client);
         SubmitJobsRequest request = new SubmitJobsRequest();
+        JSONObject input = new JSONObject();
+        input.put("Location", ossLocation);
+        input.put("Bucket", "ctop-media");
+        input.put("Object", videoPath);
+        request.setInput(input.toJSONString());
         JSONObject videoWatermarkInput = new JSONObject();
         videoWatermarkInput.put("Location", ossLocation);
         videoWatermarkInput.put("Bucket", "ctop-media");
-        videoWatermarkInput.put("Object", videoPath);
+        videoWatermarkInput.put("Object", waterMarkPath);
         JSONObject videoWatermark = new JSONObject();
         videoWatermark.put("WaterMarkTemplateId", watermarkTemplateId);
         videoWatermark.put("Type", "Image");
@@ -286,14 +294,8 @@ public class MpsUtils {
         videoWatermark.put("Height", height);
         videoWatermark.put("Dx", "0");
         videoWatermark.put("Dy", "0");
-        String outputOSSObject;
-        try {
-            outputOSSObject = URLEncoder.encode(waterMarkPath, "utf-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException("output URL encode failed");
-        }
         JSONObject output = new JSONObject();
-        output.put("OutputObject", outputOSSObject);
+        output.put("OutputObject", outputFilename);
         JSONArray watermarks = new JSONArray();
         watermarks.add(videoWatermark);
         output.put("WaterMarks", watermarks.toJSONString());