Search in sources :

Example 1 with ProcessMediaRequest

use of com.tencentcloudapi.vod.v20180717.models.ProcessMediaRequest 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)

Example 2 with ProcessMediaRequest

use of com.tencentcloudapi.vod.v20180717.models.ProcessMediaRequest in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method snapshotCover.

/**
 * {@inheritDoc}
 */
@Override
public String snapshotCover(String fileId, long screenshotTmplId, float timePosition) throws CloudSDKException {
    try {
        ProcessMediaRequest req = new ProcessMediaRequest();
        MediaProcessTaskInput mediaProcessTaskInput = new MediaProcessTaskInput();
        CoverBySnapshotTaskInput[] coverBySnapshotTaskInputs = new CoverBySnapshotTaskInput[1];
        CoverBySnapshotTaskInput coverBySnapshotTaskInput = new CoverBySnapshotTaskInput();
        coverBySnapshotTaskInput.setDefinition(screenshotTmplId);
        coverBySnapshotTaskInput.setPositionType("Time");
        coverBySnapshotTaskInput.setPositionValue(timePosition);
        coverBySnapshotTaskInputs[0] = coverBySnapshotTaskInput;
        mediaProcessTaskInput.setCoverBySnapshotTaskSet(coverBySnapshotTaskInputs);
        req.setMediaProcessTask(mediaProcessTaskInput);
        req.setFileId(fileId);
        ProcessMediaResponse resp = vodClient.ProcessMedia(req);
        if (StringUtils.isBlank(resp.getTaskId())) {
            throw new CloudSDKException("Snapshot 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) CoverBySnapshotTaskInput(com.tencentcloudapi.vod.v20180717.models.CoverBySnapshotTaskInput)

Aggregations

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