|
@@ -8,6 +8,7 @@ import com.aliyuncs.exceptions.ClientException;
|
|
|
import com.aliyuncs.exceptions.ServerException;
|
|
|
import com.aliyuncs.mts.model.v20140618.*;
|
|
|
import com.aliyuncs.profile.DefaultProfile;
|
|
|
+import com.google.gson.Gson;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.annotation.PropertySource;
|
|
|
|
|
@@ -22,9 +23,43 @@ public class MpsUtils {
|
|
|
public static final String ossLocation = "oss-cn-beijing";
|
|
|
public static final String ossBucket = "ctop-part";
|
|
|
public static void main(String[] args){
|
|
|
- String[] a = {"1","2","3","4","5"};
|
|
|
- combinationSelect(a,3);
|
|
|
- arrangementSelect(a,3);
|
|
|
+// 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));
|
|
|
+
|
|
|
+// MpsUtils mpsUtils = new MpsUtils();
|
|
|
+// List<String> list = new ArrayList<>();
|
|
|
+// list.add("v1.mp4");
|
|
|
+// String jobId = mpsUtils.mergeOneVideo("v1.mp4",list,"v1.mp4");
|
|
|
+// try {
|
|
|
+// while (true){
|
|
|
+// QueryJobListResponse.Job job = mpsUtils.getJobStatus(jobId);
|
|
|
+// job.getOutput().getOutputFile().getObject();
|
|
|
+// System.out.println(new Gson().toJson(job));
|
|
|
+// Thread.sleep(5000L);
|
|
|
+// }
|
|
|
+// } catch (InterruptedException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryJobListResponse.Job getJobStatus(String jobId){
|
|
|
+ QueryJobListResponse.Job job = null;
|
|
|
+ IAcsClient client = getClient();
|
|
|
+ QueryJobListRequest request = new QueryJobListRequest();
|
|
|
+ request.setJobIds(jobId);
|
|
|
+ try {
|
|
|
+ QueryJobListResponse response = client.getAcsResponse(request);
|
|
|
+ System.out.println(new Gson().toJson(response.getJobList().get(0)));
|
|
|
+ job = response.getJobList().get(0);
|
|
|
+ } catch (ClientException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return job;
|
|
|
}
|
|
|
/**
|
|
|
* 排列计算公式A<sup>m</sup><sub>n</sub> = n!/(n - m)!
|
|
@@ -155,8 +190,7 @@ public class MpsUtils {
|
|
|
videos.add(startPart);
|
|
|
videos.addAll(videoPart);
|
|
|
videos.add(endPart);
|
|
|
- mergeVideo(client,pipelineId,videos,outputFilename);
|
|
|
- return outputFilename;
|
|
|
+ return mergeVideo(client,pipelineId,videos,outputFilename);
|
|
|
}
|
|
|
|
|
|
public String mergeVideo(IAcsClient client, String pipelineId, List<String> videos, String outputName){
|
|
@@ -193,14 +227,15 @@ public class MpsUtils {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- String outputOssObject;
|
|
|
- try {
|
|
|
- outputOssObject = URLEncoder.encode(outputName, "utf-8");
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- throw new RuntimeException("output URL encode failed");
|
|
|
- }
|
|
|
+// String outputOssObject;
|
|
|
+// try {
|
|
|
+// outputOssObject = URLEncoder.encode(outputName, "utf-8");
|
|
|
+// outputOssObject = outputName;
|
|
|
+// } catch (UnsupportedEncodingException e) {
|
|
|
+// throw new RuntimeException("output URL encode failed");
|
|
|
+// }
|
|
|
JSONObject output = new JSONObject();
|
|
|
- output.put("OutputObject", outputOssObject);
|
|
|
+ output.put("OutputObject", outputName);
|
|
|
JSONObject video = new JSONObject();
|
|
|
video.put("Width", "720");
|
|
|
video.put("Height", "1280");
|
|
@@ -234,6 +269,8 @@ public class MpsUtils {
|
|
|
return jobId;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public String getPipelineId(IAcsClient client){
|
|
|
String pipelineId = null;
|
|
|
// 创建API请求并设置参数
|