Search in sources :

Example 1 with CloudSDKException

use of com.mizhousoft.cloudsdk.CloudSDKException 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 CloudSDKException

use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method getMediaType.

private MediaTypeEnum getMediaType(File mediaFile) throws CloudSDKException {
    String extension = FilenameUtils.getExtension(mediaFile.getName());
    MediaTypeEnum mediaType = MediaTypeEnum.get(extension.toLowerCase(Locale.US));
    if (null == mediaType) {
        throw new CloudSDKException("Media type does not supported.");
    }
    return mediaType;
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) MediaTypeEnum(com.mizhousoft.tencent.vod.constants.MediaTypeEnum)

Example 3 with CloudSDKException

use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method deleteVideo.

/**
 * {@inheritDoc}
 */
@Override
public void deleteVideo(String fileId) throws CloudSDKException {
    try {
        DeleteMediaRequest req = new DeleteMediaRequest();
        req.setFileId(fileId);
        DeleteMediaResponse resp = vodClient.DeleteMedia(req);
        LOG.info("Delete video successfully. requestid is {}.", resp.getRequestId());
    } catch (TencentCloudSDKException e) {
        throw new CloudSDKException(e.getErrorCode(), e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) DeleteMediaRequest(com.tencentcloudapi.vod.v20180717.models.DeleteMediaRequest) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) DeleteMediaResponse(com.tencentcloudapi.vod.v20180717.models.DeleteMediaResponse)

Example 4 with CloudSDKException

use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method getCoverType.

private CoverTypeEnum getCoverType(File coverFile) throws CloudSDKException {
    String extension = FilenameUtils.getExtension(coverFile.getName());
    CoverTypeEnum coverType = CoverTypeEnum.get(extension.toLowerCase(Locale.US));
    if (null == coverType) {
        throw new CloudSDKException("Cover type does not supported.");
    }
    return coverType;
}
Also used : CoverTypeEnum(com.mizhousoft.tencent.vod.constants.CoverTypeEnum) CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException)

Example 5 with CloudSDKException

use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method pullEvents.

/**
 * {@inheritDoc}
 */
@Override
public List<VodEvent> pullEvents() throws CloudSDKException {
    try {
        PullEventsRequest req = new PullEventsRequest();
        PullEventsResponse resp = vodClient.PullEvents(req);
        EventContent[] list = resp.getEventSet();
        if (null != list) {
            List<VodEvent> events = new ArrayList<>(list.length);
            for (EventContent item : list) {
                VodEvent event = convertToEvent(item);
                events.add(event);
            }
            return events;
        }
        return new ArrayList<>(0);
    } catch (TencentCloudSDKException e) {
        throw new CloudSDKException(e.getErrorCode(), e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ArrayList(java.util.ArrayList) EventContent(com.tencentcloudapi.vod.v20180717.models.EventContent) PullEventsResponse(com.tencentcloudapi.vod.v20180717.models.PullEventsResponse) PullEventsRequest(com.tencentcloudapi.vod.v20180717.models.PullEventsRequest) VodEvent(com.mizhousoft.cloudsdk.vod.event.VodEvent)

Aggregations

CloudSDKException (com.mizhousoft.cloudsdk.CloudSDKException)44 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)14 Test (org.junit.Test)13 URL (java.net.URL)8 ObjectMetadata (com.mizhousoft.cloudsdk.oss.ObjectMetadata)6 File (java.io.File)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 RecognitionResult (com.mizhousoft.cloudsdk.nlp.RecognitionResult)3 Date (java.util.Date)3 GeneratePresignedUrlRequest (com.aliyun.oss.model.GeneratePresignedUrlRequest)2 TempCredential (com.mizhousoft.cloudsdk.TempCredential)2 OSSTempCredential (com.mizhousoft.cloudsdk.oss.OSSTempCredential)2 MediaMeta (com.mizhousoft.cloudsdk.vod.MediaMeta)2 CoverTypeEnum (com.mizhousoft.tencent.vod.constants.CoverTypeEnum)2 MediaTypeEnum (com.mizhousoft.tencent.vod.constants.MediaTypeEnum)2 GeneratePresignedUrlRequest (com.qcloud.cos.model.GeneratePresignedUrlRequest)2 VinOCRRequest (com.tencentcloudapi.ocr.v20181119.models.VinOCRRequest)2 VinOCRResponse (com.tencentcloudapi.ocr.v20181119.models.VinOCRResponse)2 CoverBySnapshotTaskInput (com.tencentcloudapi.vod.v20180717.models.CoverBySnapshotTaskInput)2