List of usage examples for com.amazonaws.services.elastictranscoder.model CreateJobOutput CreateJobOutput
CreateJobOutput
From source file:com.amediamanager.service.VideoServiceImpl.java
License:Apache License
@Override public void createVideoPreview(Video video) { String pipelineId = config.getProperty(ConfigProps.TRANSCODE_PIPELINE); String presetId = config.getProperty(ConfigProps.TRANSCODE_PRESET); if (pipelineId == null || presetId == null) { return;//from w w w . jav a 2 s .com } CreateJobRequest encodeJob = new CreateJobRequest().withPipelineId(pipelineId) .withInput(new JobInput().withKey(video.getOriginalKey()).withAspectRatio("auto") .withContainer("auto").withFrameRate("auto").withInterlaced("auto").withResolution("auto")) .withOutputKeyPrefix("uploads/converted/" + video.getOwner() + "/") .withOutput(new CreateJobOutput().withKey(UUID.randomUUID().toString()).withPresetId(presetId) .withThumbnailPattern("thumbs/" + UUID.randomUUID().toString() + "-{count}")); try { CreateJobResult result = transcoderClient.createJob(encodeJob); video.setTranscodeJobId(result.getJob().getId()); video.setThumbnailKey("static/img/in_progress_poster.png"); save(video); } catch (AmazonServiceException e) { LOG.error("Failed creating transcode job for video {}", video.getId(), e); } }
From source file:org.alanwilliamson.amazon.transcoder.job.Create.java
License:Open Source License
private CreateJobOutput getCreateJobOutput(cfStructData d) throws cfmRunTimeException { CreateJobOutput cjo = new CreateJobOutput(); if (d.containsKey("presetid")) cjo.setPresetId(d.getData("presetid").getString()); if (d.containsKey("key")) cjo.setKey(d.getData("key").getString()); if (d.containsKey("rotate")) cjo.setRotate(d.getData("rotate").getString()); if (d.containsKey("segmentduration")) cjo.setSegmentDuration(d.getData("segmentduration").getString()); if (d.containsKey("encryption")) cjo.setEncryption(getEncryption((cfStructData) d.getData("encryption"))); if (d.containsKey("thumbnailencryption")) cjo.setThumbnailEncryption(getEncryption((cfStructData) d.getData("thumbnailencryption"))); if (d.containsKey("thumbnailpattern")) cjo.setThumbnailPattern(d.getData("thumbnailpattern").getString()); // Handle the watermarks if (d.containsKey("watermarks") && d.getData("watermarks") instanceof cfArrayData) { List<JobWatermark> watermarks = new LinkedList(); cfArrayData arr = (cfArrayData) d.getData("watermarks"); for (int x = 0; x < arr.size(); x++) { cfStructData s = (cfStructData) arr.getData(x + 1); JobWatermark w = new JobWatermark(); if (s.containsKey("encryption")) w.setEncryption(getEncryption((cfStructData) s.getData("encryption"))); if (s.containsKey("inputkey")) w.setInputKey(s.getData("inputkey").getString()); if (s.containsKey("presetwatermarkid")) w.setPresetWatermarkId(s.getData("presetwatermarkid").getString()); watermarks.add(w);/*from ww w . ja va 2 s. c o m*/ } cjo.setWatermarks(watermarks); } // Set the composition if (d.containsKey("composition") && d.getData("composition") instanceof cfArrayData) { List<Clip> clips = new LinkedList(); cfArrayData arr = (cfArrayData) d.getData("composition"); for (int x = 0; x < arr.size(); x++) { cfStructData s = (cfStructData) arr.getData(x + 1); Clip clip = new Clip(); TimeSpan ts = new TimeSpan(); clip.setTimeSpan(ts); if (s.containsKey("starttime")) ts.setStartTime(s.getData("starttime").getString()); if (s.containsKey("duration")) ts.setDuration(s.getData("duration").getString()); clips.add(clip); } cjo.setComposition(clips); } // handle the captions if (d.containsKey("captions") && d.getData("captions") instanceof cfStructData) { Captions c = new Captions(); cfStructData s = (cfStructData) d.getData("captions"); if (s.containsKey("mergepolicy")) c.setMergePolicy(s.getData("mergepolicy").getString()); // CaptionFormat if (s.containsKey("captionformat") && s.getData("captionformat") instanceof cfArrayData) { List<CaptionFormat> captionFormatList = new LinkedList(); cfArrayData arr = (cfArrayData) s.getData("captionformat"); for (int x = 0; x < arr.size(); x++) { cfStructData ss = (cfStructData) arr.getData(x + 1); CaptionFormat cf = new CaptionFormat(); if (ss.containsKey("encryption")) cf.setEncryption(getEncryption((cfStructData) ss.get("encryption"))); if (ss.containsKey("format")) cf.setFormat(ss.getData("format").getString()); if (ss.containsKey("pattern")) cf.setPattern(ss.getData("pattern").getString()); captionFormatList.add(cf); } c.setCaptionFormats(captionFormatList); } cjo.setCaptions(c); } // handle the album art if (d.containsKey("albumart") && d.getData("albumart") instanceof cfStructData) { JobAlbumArt ja = new JobAlbumArt(); cfStructData s = (cfStructData) d.getData("albumart"); if (s.containsKey("mergepolicy")) ja.setMergePolicy(s.getData("mergepolicy").getString()); // artwork if (s.containsKey("artwork") && s.getData("artwork") instanceof cfArrayData) { List<Artwork> artworkList = new LinkedList(); cfArrayData arr = (cfArrayData) s.getData("artwork"); for (int x = 0; x < arr.size(); x++) { cfStructData ss = (cfStructData) arr.getData(x + 1); Artwork a = new Artwork(); if (ss.containsKey("encryption")) a.setEncryption(getEncryption((cfStructData) ss.get("encryption"))); if (ss.containsKey("albumartformat")) a.setAlbumArtFormat(ss.getData("albumartformat").getString()); if (ss.containsKey("inputkey")) a.setInputKey(ss.getData("inputkey").getString()); if (ss.containsKey("maxheight")) a.setMaxHeight(ss.getData("maxheight").getString()); if (ss.containsKey("maxwidth")) a.setMaxWidth(ss.getData("maxwidth").getString()); if (ss.containsKey("paddingpolicy")) a.setPaddingPolicy(ss.getData("paddingpolicy").getString()); if (ss.containsKey("sizingpolicy")) a.setSizingPolicy(ss.getData("sizingpolicy").getString()); artworkList.add(a); } ja.setArtwork(artworkList); } cjo.setAlbumArt(ja); } return cjo; }
From source file:org.nuxeo.aws.elastictranscoder.AWSElasticTranscoder.java
License:Open Source License
protected void createElasticTranscoderJob() { // (using code from the AWS code sample in // JobStatusNotificationsSample.java) // Setup the job input JobInput jobInput = new JobInput().withKey(inputKey); // We create just one job here. Look at the code sample in // JobStatusNotificationsSample.java to see how to create several jobs // in one call. CreateJobOutput output = new CreateJobOutput().withKey(outputKey); output.withPresetId(presetId);//from www. j a v a2s.c o m // Create a job on the specified pipeline and get the job ID CreateJobRequest createJobRequest = new CreateJobRequest(); createJobRequest.withPipelineId(pipelineId); createJobRequest.withInput(jobInput); createJobRequest.withOutput(output); CreateJobResult cjr = genericAwsClient.getElasticTranscoder().createJob(createJobRequest); awsJobId = cjr.getJob().getId(); }