Example usage for com.amazonaws.services.elastictranscoder.model Thumbnails Thumbnails

List of usage examples for com.amazonaws.services.elastictranscoder.model Thumbnails Thumbnails

Introduction

In this page you can find the example usage for com.amazonaws.services.elastictranscoder.model Thumbnails Thumbnails.

Prototype

Thumbnails

Source Link

Usage

From source file:com.amediamanager.config.ElasticTranscoderPipelineResource.java

License:Apache License

private String provisionPreset() {
    String presetId = config.getProperty(ConfigProps.TRANSCODE_PRESET);

    if (presetId == null) {
        LOG.info("Provisioning ETS Preset.");
        state = ProvisionState.PROVISIONING;
        Map<String, String> codecOptions = new HashMap<String, String>();
        codecOptions.put("Profile", "main");
        codecOptions.put("Level", "3.1");
        codecOptions.put("MaxReferenceFrames", "3");

        VideoParameters video = new VideoParameters().withCodec("H.264").withCodecOptions(codecOptions)
                .withKeyframesMaxDist("90").withFixedGOP("false").withBitRate("2200").withFrameRate("30")
                .withMaxWidth("1280").withMaxHeight("720").withSizingPolicy("ShrinkToFit")
                .withPaddingPolicy("NoPad").withDisplayAspectRatio("auto");

        AudioParameters audio = new AudioParameters().withCodec("AAC").withSampleRate("44100")
                .withBitRate("160").withChannels("2");

        Thumbnails thumbnails = new Thumbnails().withFormat("png").withInterval("60").withMaxWidth("500")
                .withMaxHeight("300").withSizingPolicy("ShrinkToFit").withPaddingPolicy("NoPad");

        CreatePresetRequest presetRequest = new CreatePresetRequest()
                .withName("amm-reinvent-preset-"
                        + UUID.randomUUID().toString().replace("-", "").substring(0, 20).toUpperCase())
                .withDescription("Preset used by aMediaManager re:Invent 2013").withContainer("mp4")
                .withVideo(video).withAudio(audio).withThumbnails(thumbnails);

        try {/*from ww w.ja v  a 2 s  . c  o m*/
            CreatePresetResult result = transcoderClient.createPreset(presetRequest);
            presetId = result.getPreset().getId();
            config.getConfigurationProvider().persistNewProperty(ConfigProps.TRANSCODE_PRESET, presetId);
            LOG.info("Preset {} created. Persisting to configuration provider.", presetId);
        } catch (AmazonServiceException e) {
            LOG.error("Failed creating transcoder preset {}", presetRequest.getName(), e);
            state = ProvisionState.UNPROVISIONED;
        }
    }
    return presetId;
}