use of com.tencentcloudapi.vod.v20180717.models.TranscodeTaskInput in project cloud-sdk by mizhousoft.
the class QCloudVODServiceImpl method transcode.
/**
* {@inheritDoc}
*/
@Override
public String transcode(String fileId, long transcodeTmplId, long screenshotTmplId, float timePosition) throws CloudSDKException {
try {
MediaProcessTaskInput mediaProcessTaskInput = new MediaProcessTaskInput();
CoverBySnapshotTaskInput coverBySnapshotTaskInput = new CoverBySnapshotTaskInput();
coverBySnapshotTaskInput.setDefinition(screenshotTmplId);
coverBySnapshotTaskInput.setPositionType("Time");
coverBySnapshotTaskInput.setPositionValue(timePosition);
CoverBySnapshotTaskInput[] coverBySnapshotTaskInputs = new CoverBySnapshotTaskInput[1];
coverBySnapshotTaskInputs[0] = coverBySnapshotTaskInput;
mediaProcessTaskInput.setCoverBySnapshotTaskSet(coverBySnapshotTaskInputs);
TranscodeTaskInput transcodeTaskInput = new TranscodeTaskInput();
transcodeTaskInput.setDefinition(transcodeTmplId);
TranscodeTaskInput[] transcodeTasks = new TranscodeTaskInput[1];
transcodeTasks[0] = transcodeTaskInput;
mediaProcessTaskInput.setTranscodeTaskSet(transcodeTasks);
ProcessMediaRequest req = new ProcessMediaRequest();
req.setMediaProcessTask(mediaProcessTaskInput);
req.setFileId(fileId);
ProcessMediaResponse resp = vodClient.ProcessMedia(req);
if (StringUtils.isBlank(resp.getTaskId())) {
throw new CloudSDKException("Transcode cover failed, response: " + ProcessMediaResponse.toJsonString(resp));
}
return resp.getTaskId();
} catch (TencentCloudSDKException e) {
throw new CloudSDKException(e.getErrorCode(), e.getMessage(), e);
}
}
Aggregations