Search in sources :

Example 1 with MediaTranscodeItem

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

the class QCloudVODServiceImpl method buildMediaMeta.

private MediaMeta buildMediaMeta(String fileId, MediaBasicInfo basicInfo, MediaMetaData metaData, MediaTranscodeInfo transcodeInfo) {
    MediaMeta midiaMeta = new MediaMeta();
    midiaMeta.setFileId(fileId);
    if (null != basicInfo) {
        midiaMeta.setName(basicInfo.getName());
        midiaMeta.setType(basicInfo.getType());
        midiaMeta.setMediaUrl(basicInfo.getMediaUrl());
        midiaMeta.setCoverUrl(basicInfo.getCoverUrl());
    }
    if (null != metaData) {
        midiaMeta.setDuration(metaData.getDuration().intValue());
        midiaMeta.setMediaFileSize(metaData.getSize());
        MediaVideoStreamItem[] videoStreams = metaData.getVideoStreamSet();
        if (!ArrayUtils.isEmpty(videoStreams)) {
            MediaVideoStreamItem videoStream = videoStreams[0];
            String codec = videoStream.getCodec();
            midiaMeta.setCodec(codec);
        }
    }
    if (null != transcodeInfo) {
        MediaTranscodeItem[] list = ArrayUtils.nullToEmpty(transcodeInfo.getTranscodeSet(), MediaTranscodeItem[].class);
        for (int i = list.length - 1; i >= 0; --i) {
            MediaTranscodeItem item = list[i];
            MediaVideoStreamItem[] videoStreams = item.getVideoStreamSet();
            if (ArrayUtils.isEmpty(videoStreams)) {
                continue;
            }
            MediaVideoStreamItem videoStream = videoStreams[0];
            String codec = videoStream.getCodec();
            if (MediaCodecEnum.H264.isSelf(codec)) {
                midiaMeta.setCodec(codec);
                midiaMeta.setDuration(item.getDuration().intValue());
                midiaMeta.setMediaFileSize(item.getSize());
                midiaMeta.setMediaUrl(item.getUrl());
                break;
            }
        }
    }
    return midiaMeta;
}
Also used : MediaTranscodeItem(com.tencentcloudapi.vod.v20180717.models.MediaTranscodeItem) MediaMeta(com.mizhousoft.cloudsdk.vod.MediaMeta) MediaVideoStreamItem(com.tencentcloudapi.vod.v20180717.models.MediaVideoStreamItem)

Aggregations

MediaMeta (com.mizhousoft.cloudsdk.vod.MediaMeta)1 MediaTranscodeItem (com.tencentcloudapi.vod.v20180717.models.MediaTranscodeItem)1 MediaVideoStreamItem (com.tencentcloudapi.vod.v20180717.models.MediaVideoStreamItem)1