Search in sources :

Example 1 with TranscodeTaskInput

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);
    }
}
Also used : ProcessMediaResponse(com.tencentcloudapi.vod.v20180717.models.ProcessMediaResponse) CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ProcessMediaRequest(com.tencentcloudapi.vod.v20180717.models.ProcessMediaRequest) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) MediaProcessTaskInput(com.tencentcloudapi.vod.v20180717.models.MediaProcessTaskInput) TranscodeTaskInput(com.tencentcloudapi.vod.v20180717.models.TranscodeTaskInput) CoverBySnapshotTaskInput(com.tencentcloudapi.vod.v20180717.models.CoverBySnapshotTaskInput)

Aggregations

CloudSDKException (com.mizhousoft.cloudsdk.CloudSDKException)1 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)1 CoverBySnapshotTaskInput (com.tencentcloudapi.vod.v20180717.models.CoverBySnapshotTaskInput)1 MediaProcessTaskInput (com.tencentcloudapi.vod.v20180717.models.MediaProcessTaskInput)1 ProcessMediaRequest (com.tencentcloudapi.vod.v20180717.models.ProcessMediaRequest)1 ProcessMediaResponse (com.tencentcloudapi.vod.v20180717.models.ProcessMediaResponse)1 TranscodeTaskInput (com.tencentcloudapi.vod.v20180717.models.TranscodeTaskInput)1