|
|
@@ -0,0 +1,255 @@
|
|
|
+//package com.cnd3b.service;
|
|
|
+//
|
|
|
+//import com.alibaba.fastjson.JSONArray;
|
|
|
+//import com.alibaba.fastjson.JSONObject;
|
|
|
+//import com.aliyuncs.DefaultAcsClient;
|
|
|
+//import com.aliyuncs.IAcsClient;
|
|
|
+//import com.aliyuncs.exceptions.ClientException;
|
|
|
+//import com.aliyuncs.exceptions.ServerException;
|
|
|
+//import com.aliyuncs.mts.model.v20140618.*;
|
|
|
+//import com.aliyuncs.profile.DefaultProfile;
|
|
|
+//import com.cnd3b.common.BaseClass;
|
|
|
+//import com.cnd3b.utility.WebRequest;
|
|
|
+//import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
+//import p2.common.parse.J;
|
|
|
+//
|
|
|
+//import java.io.UnsupportedEncodingException;
|
|
|
+//import java.net.URLEncoder;
|
|
|
+//
|
|
|
+//public class OssService extends BaseClass implements Runnable {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// System.err.println("OssService");
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// private static String accessKeyId = "LTAI5tASc17g95ABAqwUAqNS";
|
|
|
+// private static String accessKeySecret = "UUs8gERP91X8HGeWgeOa6jsAIGQhhK";
|
|
|
+// private static String mpsRegionId = "cn-beijing";
|
|
|
+// private static String pipelineId = "189f4d23997941089318d5117efc1857";
|
|
|
+// private static String templateId = "S00000001-200040";
|
|
|
+// private static String ossLocation = "oss-cn-beijing";
|
|
|
+// private static String ossBucket = "jiusheng11";
|
|
|
+// private static String ossInputObject = "change/实木地暖地板技术视频.mov";
|
|
|
+// private static String ossOutputObject = "change/实木地暖地板技术视频_1.mov";
|
|
|
+//
|
|
|
+// public static void main(String[] args) throws UnsupportedEncodingException, ClientException {
|
|
|
+//
|
|
|
+//// transcoding();
|
|
|
+//// queryMediaListByURL();
|
|
|
+//
|
|
|
+//// AddMedia("http://jiusheng11.oss-cn-beijing.aliyuncs.com/11/实木地暖地板技术视频.mp4");
|
|
|
+// //transcoding("11/实木地暖地板技术视频.mp4", "11/实木地暖地板技术视频_2.mov");
|
|
|
+// submitMediaInfoJob("tt/英文版1分钟.mp4");
|
|
|
+//// submitAnalysisJob("tt/123.mp4");
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static void transcoding(String ossInputObject, String ossOutputObject) {
|
|
|
+// // 创建DefaultAcsClient实例并初始化
|
|
|
+// DefaultProfile profile = DefaultProfile.getProfile(
|
|
|
+// mpsRegionId, // 地域ID
|
|
|
+// accessKeyId, // RAM账号的AccessKey ID
|
|
|
+// accessKeySecret); // RAM账号Access Key Secret
|
|
|
+// IAcsClient client = new DefaultAcsClient(profile);
|
|
|
+// // 创建API请求并设置参数
|
|
|
+// SubmitJobsRequest request = new SubmitJobsRequest();
|
|
|
+// // Input
|
|
|
+// JSONObject input = new JSONObject();
|
|
|
+// input.put("Location", ossLocation);
|
|
|
+// input.put("Bucket", ossBucket);
|
|
|
+// try {
|
|
|
+// input.put("Object", URLEncoder.encode(ossInputObject, "utf-8"));
|
|
|
+// } catch (UnsupportedEncodingException e) {
|
|
|
+// throw new RuntimeException("input URL encode failed");
|
|
|
+// }
|
|
|
+// request.setInput(input.toJSONString());
|
|
|
+// // Output
|
|
|
+// String outputOSSObject;
|
|
|
+// try {
|
|
|
+// outputOSSObject = URLEncoder.encode(ossOutputObject, "utf-8");
|
|
|
+// } catch (UnsupportedEncodingException e) {
|
|
|
+// throw new RuntimeException("output URL encode failed");
|
|
|
+// }
|
|
|
+// JSONObject output = new JSONObject();
|
|
|
+// output.put("OutputObject", outputOSSObject);
|
|
|
+// // Ouput->Container
|
|
|
+//// JSONObject container = new JSONObject();
|
|
|
+//// container.put("Format", "mp4");
|
|
|
+//// output.put("Container", container.toJSONString());
|
|
|
+// // Ouput->Video
|
|
|
+//// JSONObject video = new JSONObject();
|
|
|
+//// video.put("Codec", "H.264");
|
|
|
+//// video.put("Bitrate", "1500");
|
|
|
+//// video.put("Width", "1280");
|
|
|
+//// video.put("Fps", "25");
|
|
|
+//// output.put("Video", video.toJSONString());
|
|
|
+// // Ouput->Audio
|
|
|
+//// JSONObject audio = new JSONObject();
|
|
|
+//// audio.put("Codec", "AAC");
|
|
|
+//// audio.put("Bitrate", "128");
|
|
|
+//// audio.put("Channels", "2");
|
|
|
+//// audio.put("Samplerate", "44100");
|
|
|
+//// output.put("Audio", audio.toJSONString());
|
|
|
+// // Ouput->TemplateId
|
|
|
+// output.put("TemplateId", "S00000001-200010");
|
|
|
+// 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()) {
|
|
|
+// 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();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //根据视频源OSS地址查询媒体信息, 如: 媒体ID, 媒体状态及其他属性
|
|
|
+// private static void queryMediaListByURL() throws ClientException, UnsupportedEncodingException {
|
|
|
+// String ossHost = "http://jiusheng11.oss-cn-beijing.aliyuncs.com/";
|
|
|
+// String ossObject = "22/实木地暖地板技术视频.mp4";
|
|
|
+// //ossObject需要符合rfc3986标准
|
|
|
+// String rfc3986Object = encodeByRFC3986(ossObject);
|
|
|
+// // 创建DefaultAcsClient实例并初始化
|
|
|
+// DefaultProfile profile = DefaultProfile.getProfile(
|
|
|
+// mpsRegionId, // 地域ID
|
|
|
+// accessKeyId, // RAM账号的AccessKey ID
|
|
|
+// accessKeySecret); // RAM账号Access Key Secret
|
|
|
+// DefaultAcsClient client = new DefaultAcsClient(profile);
|
|
|
+// //查询媒体
|
|
|
+// QueryMediaListByURLRequest request2 = new QueryMediaListByURLRequest();
|
|
|
+// request2.setFileURLs(ossHost + rfc3986Object);
|
|
|
+// QueryMediaListByURLResponse response = client.getAcsResponse(request2);
|
|
|
+// System.out.println(JSONObject.toJSONString(response.getMediaList()));
|
|
|
+// }
|
|
|
+//
|
|
|
+// private static String encodeByRFC3986(String object) throws UnsupportedEncodingException {
|
|
|
+// StringBuilder builder = new StringBuilder();
|
|
|
+// String[] segments = object.split("/");
|
|
|
+// for (int i = 0; i < segments.length; i++) {
|
|
|
+// builder.append(percentEncode(segments[i]));
|
|
|
+// if (i != segments.length - 1) {
|
|
|
+// builder.append("/");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return builder.toString();
|
|
|
+// }
|
|
|
+//
|
|
|
+// private static String percentEncode(String value) throws UnsupportedEncodingException {
|
|
|
+// if (value == null) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// return URLEncoder.encode(value, "UTF-8").replace("+", "%20").replace("*", "%2A").replace("%7E", "~");
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// private static final String REGION = "cn-beijing";
|
|
|
+// private static final String mtsEndpoint = "mts." + mpsRegionId + ".aliyuncs.com";
|
|
|
+// private static DefaultAcsClient aliyunClient;
|
|
|
+//
|
|
|
+//
|
|
|
+// public static void AddMedia(String fileURL) {
|
|
|
+// try {
|
|
|
+// DefaultProfile.addEndpoint(REGION, REGION, "Mts", mtsEndpoint);
|
|
|
+// } catch (ClientException e) {
|
|
|
+// System.out.print(ExceptionUtils.getStackTrace(e));
|
|
|
+// System.exit(1);
|
|
|
+// }
|
|
|
+// aliyunClient = new DefaultAcsClient(DefaultProfile.getProfile(REGION, accessKeyId, accessKeySecret));
|
|
|
+// AddMediaRequest request = new AddMediaRequest();
|
|
|
+// request.setFileURL(fileURL);
|
|
|
+//// request.setMediaWorkflowId("829bed0300994057a49e4f16de95****");
|
|
|
+//// request.setMediaWorkflowId("064a10f717d84a92b537f51b2a8aae4a");
|
|
|
+// try {
|
|
|
+// AddMediaResponse response = aliyunClient.getAcsResponse(request);
|
|
|
+// System.out.println(JSONObject.toJSONString(response));
|
|
|
+// } catch (ServerException e) {
|
|
|
+// System.out.println("Code:" + e.getErrCode() + " Msg:" + e.getMessage());
|
|
|
+// } catch (ClientException e) {
|
|
|
+// System.out.println("Code:" + e.getErrCode() + " Msg:" + e.getMessage());
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static void submitMediaInfoJob(String Object) {
|
|
|
+//
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("Bucket", ossBucket);
|
|
|
+// jsonObject.put("Location", ossLocation);
|
|
|
+// jsonObject.put("Object", Object);
|
|
|
+// String json = jsonObject.toJSONString();
|
|
|
+//
|
|
|
+//
|
|
|
+// try {
|
|
|
+// DefaultProfile.addEndpoint(REGION, REGION, "Mts", mtsEndpoint);
|
|
|
+// } catch (ClientException e) {
|
|
|
+// System.out.print(ExceptionUtils.getStackTrace(e));
|
|
|
+// System.exit(1);
|
|
|
+// }
|
|
|
+// aliyunClient = new DefaultAcsClient(DefaultProfile.getProfile(REGION, accessKeyId, accessKeySecret));
|
|
|
+//
|
|
|
+// SubmitMediaInfoJobRequest request = new SubmitMediaInfoJobRequest();
|
|
|
+// request.setInput(json);
|
|
|
+// request.setPipelineId(pipelineId);
|
|
|
+//
|
|
|
+// try {
|
|
|
+// SubmitMediaInfoJobResponse response = aliyunClient.getAcsResponse(request);
|
|
|
+// System.out.println(JSONObject.toJSONString(response));
|
|
|
+// } catch (ClientException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static void submitAnalysisJob(String Object) {
|
|
|
+//
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("Bucket", ossBucket);
|
|
|
+// jsonObject.put("Location", ossLocation);
|
|
|
+// jsonObject.put("Object", Object);
|
|
|
+// String json = jsonObject.toJSONString();
|
|
|
+//
|
|
|
+//
|
|
|
+// try {
|
|
|
+// DefaultProfile.addEndpoint(REGION, REGION, "Mts", mtsEndpoint);
|
|
|
+// } catch (ClientException e) {
|
|
|
+// System.out.print(ExceptionUtils.getStackTrace(e));
|
|
|
+// System.exit(1);
|
|
|
+// }
|
|
|
+// aliyunClient = new DefaultAcsClient(DefaultProfile.getProfile(REGION, accessKeyId, accessKeySecret));
|
|
|
+//
|
|
|
+// SubmitAnalysisJobRequest request = new SubmitAnalysisJobRequest();
|
|
|
+// request.setInput(json);
|
|
|
+// request.setPipelineId(pipelineId);
|
|
|
+//
|
|
|
+// try {
|
|
|
+// SubmitAnalysisJobResponse response = aliyunClient.getAcsResponse(request);
|
|
|
+// System.out.println(JSONObject.toJSONString(response));
|
|
|
+// } catch (ClientException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|