|
@@ -197,7 +197,43 @@ public class CloudVideoProcessUtil {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 数据万象获取截图服务
|
|
|
+ */
|
|
|
+ public static String videoCutPictureHandle(String videoPath, String outputPath) {
|
|
|
+ String auth =generateAuth(SECRET_ID,SECRET_KEY,"/snapshot",HttpMethodName.POST);
|
|
|
+ if(auth.isEmpty()){
|
|
|
+ logger.error("腾讯云Authorization获取失败");
|
|
|
+ }
|
|
|
+ //拼接请求数据万象jobs接口的参数
|
|
|
+ JSONObject input = new JSONObject();
|
|
|
+ input.put("Object", videoPath);
|
|
|
+ JSONObject output = new JSONObject();
|
|
|
+ output.put("Region", COS_LOCATION);
|
|
|
+ output.put("Bucket", COS_BUCKET_MEDIA);
|
|
|
+ output.put("Object", outputPath);
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("Input",input);
|
|
|
+ request.put("Output",output);
|
|
|
+ request.put("Time",0);
|
|
|
|
|
|
+ //请求media-1301855440.ci.ap-chongqing.myqcloud.com/snapshot 接口
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.set("Authorization", auth);
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ HttpEntity<String> requestEntity = new HttpEntity<>(request.toJSONString(), headers);
|
|
|
+ String response = null;
|
|
|
+ try {
|
|
|
+ response = restTemplate.exchange(CosConstant.URL_SNAPSHOT, HttpMethod.POST, requestEntity, String.class).getBody();
|
|
|
+ } catch (RestClientException e) {
|
|
|
+ logger.error(e.getMessage());
|
|
|
+ }
|
|
|
+ if(response.isEmpty()){
|
|
|
+ return CosConstant.URL_COS_ADDRESS+"error.jpg";
|
|
|
+ }else{
|
|
|
+ return CosConstant.URL_COS_ADDRESS+outputPath;
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 获取视频处理服务 MpsClient
|
|
|
*/
|
|
@@ -239,12 +275,18 @@ public class CloudVideoProcessUtil {
|
|
|
}
|
|
|
private static Map<String,Object> getFrameUrl(String outputPath){
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
- for(int i=0;i<15;i++){
|
|
|
+ for(int i=1;i<15;i++){
|
|
|
result.put(""+i+"",CosConstant.URL_COS_ADDRESS+outputPath.replace("${Number}",""+i+""));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private static Map<String,Object> getPictureUrl(String outputPath){
|
|
|
+ Map<String,Object> result=new HashMap<>();
|
|
|
+ result.put("0",CosConstant.URL_COS_ADDRESS+outputPath);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private static Map<String,Object> getErrorUrl(){
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
result.put("0",CosConstant.URL_COS_ADDRESS+"error.jpg");
|