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);
}
}
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;
}
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);
}
}
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;
}
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);
}
}
Aggregations