Search in sources :

Example 1 with MediaTemplateResponse

use of com.qcloud.cos.model.ciModel.template.MediaTemplateResponse in project cos-java-sdk-v5 by tencentyun.

the class AnimationTemplateDemo method createMediaTemplate.

/**
 * CreateMediaTemplate 用于新增动图模板。
 *
 * @param client
 */
public static void createMediaTemplate(COSClient client) throws UnsupportedEncodingException {
    // 1.创建模板请求对象
    MediaTemplateRequest request = new MediaTemplateRequest();
    // 2.添加请求参数 参数详情请见api接口文档
    request.setBucketName("DemoBucket-123456789");
    request.setTag("Animation");
    request.setName("TestTemplate40");
    request.getContainer().setFormat("gif");
    request.getVideo().setCodec("gif");
    request.getVideo().setWidth("1280");
    request.getVideo().setFps("15");
    request.getVideo().setAnimateOnlyKeepKeyFrame("true");
    request.getTimeInterval().setStart("0");
    request.getTimeInterval().setDuration("60");
    // 3.调用接口,获取模板响应对象
    MediaTemplateResponse response = client.createMediaTemplate(request);
    System.out.println(response);
}
Also used : MediaTemplateResponse(com.qcloud.cos.model.ciModel.template.MediaTemplateResponse) MediaTemplateRequest(com.qcloud.cos.model.ciModel.template.MediaTemplateRequest)

Example 2 with MediaTemplateResponse

use of com.qcloud.cos.model.ciModel.template.MediaTemplateResponse in project cos-java-sdk-v5 by tencentyun.

the class SnapshotTemplateDemo method createMediaTemplate.

/**
 * CreateMediaTemplate 用于新增截图模板。
 *
 * @param client
 */
public static void createMediaTemplate(COSClient client) throws UnsupportedEncodingException {
    // 1.创建模板请求对象
    MediaTemplateRequest request = new MediaTemplateRequest();
    // 2.添加请求参数 参数详情请见api接口文档
    request.setBucketName("DemoBucket-123456789");
    request.setTag("Snapshot");
    request.setName("mark-test-1");
    request.getSnapshot().setMode("Interval");
    request.getSnapshot().setWidth("1280");
    request.getSnapshot().setStart("0");
    request.getSnapshot().setCount("1");
    // 3.调用接口,获取模板响应对象
    MediaTemplateResponse response = client.createMediaTemplate(request);
    System.out.println(response);
}
Also used : MediaTemplateResponse(com.qcloud.cos.model.ciModel.template.MediaTemplateResponse) MediaTemplateRequest(com.qcloud.cos.model.ciModel.template.MediaTemplateRequest)

Example 3 with MediaTemplateResponse

use of com.qcloud.cos.model.ciModel.template.MediaTemplateResponse in project cos-java-sdk-v5 by tencentyun.

the class MediaTemplateTest method mediaTemplateTest.

@Test
public void mediaTemplateTest() {
    if (!judgeUserInfoValid()) {
        return;
    }
    MediaTemplateRequest request = new MediaTemplateRequest();
    request.setBucketName(bucket);
    request.setTag(TAG);
    request.setName(Long.valueOf(System.currentTimeMillis()).toString());
    request.getContainer().setFormat(FORMAT);
    request.getVideo().setCodec(CODEC);
    request.getVideo().setWidth(WIDTH);
    request.getVideo().setFps(FPS);
    request.getVideo().setAnimateOnlyKeepKeyFrame(ANIMATE_ONLY_KEEP_KEY_FRAME);
    request.getTimeInterval().setStart(START);
    request.getTimeInterval().setDuration(DURATION);
    MediaTemplateResponse response = cosclient.createMediaTemplate(request);
    MediaTemplateObject template = response.getTemplate();
    Assert.assertEquals(bucket, template.getBucketId());
    Assert.assertEquals(TAG, template.getTag());
    Assert.assertEquals(FORMAT, template.getTransTpl().getContainer().getFormat());
    Assert.assertEquals(CODEC, template.getTransTpl().getVideo().getCodec());
    Assert.assertEquals(START, template.getTransTpl().getTimeInterval().getStart());
    request = new MediaTemplateRequest();
    request.setBucketName(bucket);
    MediaListTemplateResponse templates = cosclient.describeMediaTemplates(request);
    List<MediaTemplateObject> templateList = templates.getTemplateList();
    Assert.assertTrue(templateList.size() >= 1);
    for (MediaTemplateObject mediaTemplateObject : templateList) {
        if (response.getTemplate().getTemplateId().equals(mediaTemplateObject.getTemplateId())) {
            Assert.assertEquals(bucket, mediaTemplateObject.getBucketId());
            Assert.assertEquals(TAG, mediaTemplateObject.getTag());
            Assert.assertEquals(FORMAT, mediaTemplateObject.getTransTpl().getContainer().getFormat());
            Assert.assertEquals(CODEC, mediaTemplateObject.getTransTpl().getVideo().getCodec());
            Assert.assertEquals(START, mediaTemplateObject.getTransTpl().getTimeInterval().getStart());
        }
    }
    request = new MediaTemplateRequest();
    request.setBucketName(bucket);
    request.setTemplateId(response.getTemplate().getTemplateId());
    Boolean aBoolean = cosclient.deleteMediaTemplate(request);
    Assert.assertTrue(aBoolean);
}
Also used : MediaTemplateResponse(com.qcloud.cos.model.ciModel.template.MediaTemplateResponse) MediaTemplateRequest(com.qcloud.cos.model.ciModel.template.MediaTemplateRequest) MediaTemplateObject(com.qcloud.cos.model.ciModel.template.MediaTemplateObject) MediaListTemplateResponse(com.qcloud.cos.model.ciModel.template.MediaListTemplateResponse) Test(org.junit.Test)

Example 4 with MediaTemplateResponse

use of com.qcloud.cos.model.ciModel.template.MediaTemplateResponse in project cos-java-sdk-v5 by tencentyun.

the class TranscodeTemplateDemo method createMediaTemplate.

/**
 * CreateMediaTemplate 用于新增转码模板。
 *
 * @param client
 */
public static void createMediaTemplate(COSClient client) throws UnsupportedEncodingException {
    // 1.创建模板请求对象
    MediaTemplateRequest request = new MediaTemplateRequest();
    // 2.添加请求参数 参数详情请见api接口文档
    request.setBucketName("DemoBucket-123456789");
    request.setTag("Transcode");
    request.setName("mark-test-2");
    request.getContainer().setFormat("mp4");
    // 2.1 添加video对象的值
    MediaVideoObject video = request.getVideo();
    video.setCodec("H.264");
    video.setProfile("high");
    video.setBitrate("1000");
    video.setWidth("1280");
    video.setFps("30");
    video.setPreset("medium");
    video.setBufSize("1000");
    video.setMaxrate("10");
    // 2.2  添加audio对象的值
    MediaAudioObject audio = request.getAudio();
    audio.setCodec("aac");
    audio.setSamplerate("44100");
    audio.setBitrate("128");
    audio.setChannels("1");
    // 2.3 添加TransConfig对象的值
    MediaTransConfigObject transConfig = request.getTransConfig();
    transConfig.setAdjDarMethod("scale");
    transConfig.setIsCheckReso("false");
    transConfig.setResoAdjMethod("1");
    // 2.4 添加TimeInterval对象的值
    MediaTimeIntervalObject timeInterval = request.getTimeInterval();
    timeInterval.setStart("0");
    timeInterval.setDuration("60");
    // 3. 调用接口 获取模板响应对象
    MediaTemplateResponse response = client.createMediaTemplate(request);
    System.out.println(response);
}
Also used : MediaTemplateResponse(com.qcloud.cos.model.ciModel.template.MediaTemplateResponse) MediaAudioObject(com.qcloud.cos.model.ciModel.job.MediaAudioObject) MediaTimeIntervalObject(com.qcloud.cos.model.ciModel.job.MediaTimeIntervalObject) MediaTemplateRequest(com.qcloud.cos.model.ciModel.template.MediaTemplateRequest) MediaTransConfigObject(com.qcloud.cos.model.ciModel.job.MediaTransConfigObject) MediaVideoObject(com.qcloud.cos.model.ciModel.job.MediaVideoObject)

Aggregations

MediaTemplateRequest (com.qcloud.cos.model.ciModel.template.MediaTemplateRequest)4 MediaTemplateResponse (com.qcloud.cos.model.ciModel.template.MediaTemplateResponse)4 MediaAudioObject (com.qcloud.cos.model.ciModel.job.MediaAudioObject)1 MediaTimeIntervalObject (com.qcloud.cos.model.ciModel.job.MediaTimeIntervalObject)1 MediaTransConfigObject (com.qcloud.cos.model.ciModel.job.MediaTransConfigObject)1 MediaVideoObject (com.qcloud.cos.model.ciModel.job.MediaVideoObject)1 MediaListTemplateResponse (com.qcloud.cos.model.ciModel.template.MediaListTemplateResponse)1 MediaTemplateObject (com.qcloud.cos.model.ciModel.template.MediaTemplateObject)1 Test (org.junit.Test)1