问题描述:
现在有个需求,需要对视频平均截9张图;参考阿里云文档(https://help.aliyun.com/document_detail/56333.html?spm=a2c4g.11186623.6.754.56b5d84aXbBrNs),发现如下问题
- 当Interval小于等于2得时候,其他参数无效,只能抽取首帧1张图(即num设置无效)
- 参考文档得抽帧截图参数部分(如下图):https://help.aliyun.com/document_detail/29253.html?spm=a2c4g.11186623.6.729.20fad84aBPIdhz ,(用了一个5s得视频测试,只有一张图,测试视频[https://gusteau-test.oss-cn-hangzhou.aliyuncs.com/component/1592380139915.mp4])(用了一个半分钟得视频测试,只有5张图,测试视频[http://gusteau-test.oss-cn-hangzhou.aliyuncs.com/material/clip/video/2020/09/21/e6u47i5g8fk.mp4])

测试代码如下
private static String accessKeyId = "xxx";private static String accessKeySecret = "xxx";private static String ossLocation = "oss-cn-hangzhou";private static String mpsRegionId = "cn-hangzhou";private static String pipelineId = "xxx";private static String ossBucket = "xxx";private static String ossInputObject = "xxx";private static String ossOutputObject = "xxx";public static void main(String[] args) {// DefaultAcsClientDefaultProfile profile = DefaultProfile.getProfile(mpsRegionId, // Region IDaccessKeyId, // AccessKey IDaccessKeySecret); // Access Key SecretIAcsClient client = new DefaultAcsClient(profile);// requestSubmitSnapshotJobRequest request = new SubmitSnapshotJobRequest();// InputJSONObject 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());// SnapshotConfigJSONObject snapshotConfig = new JSONObject();// SnapshotConfig->OutputFileJSONObject output = new JSONObject();output.put("Location", ossLocation);output.put("Bucket", ossBucket);try {output.put("Object", URLEncoder.encode(ossOutputObject, "utf-8"));} catch (UnsupportedEncodingException e) {throw new RuntimeException("output URL encode failed");}snapshotConfig.put("OutputFile", output.toJSONString());// SnapshotConfig->TimesnapshotConfig.put("Time", "0");// SnapshotConfig->Interval/NumsnapshotConfig.put("Interval", "0");snapshotConfig.put("Num", "9");// SnapshotConfig->Width/Height// snapshotConfig.put("Height", "360");// SnapshotConfigrequest.setSnapshotConfig(snapshotConfig.toJSONString());// PipelineIdrequest.setPipelineId(pipelineId);// call apiSubmitSnapshotJobResponse response;try {response = client.getAcsResponse(request);System.out.println("RequestId is:"+response.getRequestId());System.out.println("JobId is:" + response.getSnapshotJob().getId());} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {e.printStackTrace();}}
解决:
找了阿里客服,最后的解决也很简单,如果视频很短最好将FrameType设置为normal。
晕死,文档也没说鸭。
