|
@@ -269,6 +269,64 @@ public class MpsUtils {
|
|
|
return jobId;
|
|
|
}
|
|
|
|
|
|
+ public String videoWaterMark(String videoPath,String waterMarkPath,String watermarkTemplateId){
|
|
|
+ String jobId = "";
|
|
|
+ IAcsClient client = getClient();
|
|
|
+ String pipelineId = getPipelineId(client);
|
|
|
+ SubmitJobsRequest request = new SubmitJobsRequest();
|
|
|
+ JSONObject videoWatermarkInput = new JSONObject();
|
|
|
+ videoWatermarkInput.put("Location", ossLocation);
|
|
|
+ videoWatermarkInput.put("Bucket", ossBucket);
|
|
|
+ try {
|
|
|
+ videoWatermarkInput.put("Object", URLEncoder.encode(videoPath, "utf-8"));
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new RuntimeException("videoWatetmark Input URL encode failed");
|
|
|
+ }
|
|
|
+ JSONObject videoWatermark = new JSONObject();
|
|
|
+ videoWatermark.put("WaterMarkTemplateId", watermarkTemplateId);
|
|
|
+ videoWatermark.put("Type", "Image");
|
|
|
+ videoWatermark.put("InputFile", videoWatermarkInput);
|
|
|
+ videoWatermark.put("ReferPos", "BottomLeft");
|
|
|
+ videoWatermark.put("Height", "240");
|
|
|
+ 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);
|
|
|
+ JSONArray watermarks = new JSONArray();
|
|
|
+ watermarks.add(videoWatermark);
|
|
|
+ output.put("WaterMarks", watermarks.toJSONString());
|
|
|
+ // Outputs
|
|
|
+ JSONArray outputs = new JSONArray();
|
|
|
+ outputs.add(output);
|
|
|
+ request.setOutputs(outputs.toJSONString());
|
|
|
+ request.setOutputBucket(ossBucket);
|
|
|
+ request.setOutputLocation(ossLocation);
|
|
|
+ // PipelineId
|
|
|
+ request.setPipelineId(pipelineId);
|
|
|
+ SubmitJobsResponse response;
|
|
|
+ try {
|
|
|
+ response = client.getAcsResponse(request);
|
|
|
+ System.out.println("RequestId is:"+response.getRequestId());
|
|
|
+ if (response.getJobResultList().get(0).getSuccess()) {
|
|
|
+ jobId = response.getJobResultList().get(0).getJob().getJobId();
|
|
|
+ System.out.println("JobId is:" + response.getJobResultList().get(0).getJob().getJobId());
|
|
|
+ } else {
|
|
|
+ System.out.println("SubmitJobs Failed code:" + response.getJobResultList().get(0).getCode() +
|
|
|
+ " message:" + response.getJobResultList().get(0).getMessage());
|
|
|
+ }
|
|
|
+ } catch (ServerException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ClientException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return jobId;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public String getPipelineId(IAcsClient client){
|