Java 类com.amazonaws.services.elastictranscoder.model.CreateJobResult 实例源码

项目:s3_video    文件:AWSAdapter.java   
public CreateJobResult createGifJob(String pipelineId, String inputKey) {
    JobInput input = new JobInput().withKey(inputKey);

    List<CreateJobOutput> gifJobOutputs = new ArrayList<>();

    Iterator<String> gifPresetKeys = gifPresets.keySet().iterator();
    while (gifPresetKeys.hasNext()) {
        String gifPresetKey = gifPresetKeys.next(); 
        CreateJobOutput gifJob = new CreateJobOutput()
        .withKey(gifPresetKey)
        .withPresetId((String)gifPresets.get(gifPresetKey));            
        gifJobOutputs.add(gifJob);
    }

    // Create the job.
    CreateJobRequest createJobRequest = new CreateJobRequest()
        .withPipelineId(pipelineId)
        .withInput(input)
        .withOutputKeyPrefix(inputKey + "/")
        .withOutputs(gifJobOutputs);

    return transcoderClient.createJob(createJobRequest);        
}
项目:s3_video    文件:TranscodeService.java   
public List<String> push(String sourceFilePath) throws TranscodeException, IOException, InvalidNameException{
    Transcoder transcoder = transcoderRepository.getTranscoder();
    if (!"true".equalsIgnoreCase(transcoder.getIsInitialized())){
        throw new TranscodeException("Transcoder not initialized");
    }

    File inputFile = new File(sourceFilePath);
    File[] assetFiles = getAssetFiles(inputFile);

    File transcodedDirectory = null;
    if (inputFile.isDirectory()) {
        transcodedDirectory = makeDirectoryForProcessedFilesIfNotExist(inputFile, DIRECTORY_FOR_TRANSCODED_VIDEOS); 
    } 

    List<String> keys = new ArrayList<>();

    DateTime date = new DateTime();
    for (int i = 0; i < assetFiles.length; i++) {
        if (!assetFiles[i].isDirectory() && !assetFiles[i].isHidden()) {
            String key = uploadToS3(assetFiles[i]);
            logger.info("Upload to s3 complete, transcode started. This may take a while");
            CreateJobResult result = awsAdapter.createTranscodeJob(transcoder.getPipelineId(), key);
            String jobId = result.getJob().getId();
            waitForJobCompletion(transcoder.getNotificationQueueUrl(), jobId);  
            keys.add(key);

            if (transcodedDirectory != null) {
                assetFiles[i].renameTo(new File(transcodedDirectory, assetFiles[i].getName() + "_" + date.getMillis()));
            }
        }
    }

    return keys;
}
项目:s3_video    文件:TranscodeService.java   
public void pushGif(String sourceFilePath) throws TranscodeException, InvalidNameException, IOException {
    Transcoder transcoder = transcoderRepository.getTranscoder();
    if (!"true".equalsIgnoreCase(transcoder.getIsInitialized())){
        throw new TranscodeException("Transcoder not initialized");
    }

    File inputFile = new File(sourceFilePath);
    File[] assetFiles = getAssetFiles(inputFile);       
    File transcodedDirectory = null;
    if (inputFile.isDirectory()) {
        transcodedDirectory = makeDirectoryForProcessedFilesIfNotExist(inputFile, DIRECTORY_FOR_GIF_VIDEOS);
    }

    DateTime date = new DateTime();
    for (int i = 0; i < assetFiles.length; i++) {
        if (!assetFiles[i].isDirectory() && !assetFiles[i].isHidden()) {
            String key = uploadToS3(assetFiles[i]);
            logger.info("Upload to s3 complete, transcode started. This may take a while");
            CreateJobResult result = awsAdapter.createGifJob(transcoder.getPipelineId(), key);
            String jobId = result.getJob().getId();
            waitForJobCompletion(transcoder.getNotificationQueueUrl(), jobId);

            if (transcodedDirectory != null) {
                assetFiles[i].renameTo(new File(transcodedDirectory, assetFiles[i].getName() + "_" + date.getMillis()));
            }
        }
    }
}
项目:amediamanager    文件:VideoServiceImpl.java   
@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;
    }
    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);
    }
}
项目:transcoder    文件:TranscodingService.java   
public TranscodingJob transcode( final TranscodeRequest transcodeRequest )
{
    final String inputKey = transcodeRequest.getInputKey();
    final String outputKey = transcodeRequest.getOutputKey();

    // Extract TranscodingService
    logger.info( "Transcoding {} to {}.", inputKey, outputKey );
    final JobInput jobInput =
            new JobInput().withKey( inputKey ).withAspectRatio( "auto" ).withContainer( "auto" )
                    .withFrameRate( "auto" ).withInterlaced( "auto" ).withResolution( "auto" );
    final CreateJobOutput createJobOutput =
            new CreateJobOutput().withKey( outputKey ).withPresetId( ETS_PRESET_1080P ).withRotate( "auto" )
                    .withThumbnailPattern( "" );
    final CreateJobRequest jobRequest =
            new CreateJobRequest().withInput( jobInput ).withOutputs( createJobOutput )
                    .withPipelineId( MOV_TO_MP4_PIPELINE_ID );

    CreateJobResult jobResult;
    try
    {
        jobResult = this.elasticTranscoder.createJob( jobRequest );
    }
    catch ( final AmazonClientException e )
    {
        logger.error( "Error creating ElasticTranscoder Job!", e );
        return null;
    }

    if ( jobResult.getJob() == null )
    {
        logger.error( "Job is null.  Something went wrong!" );
        return null;
    }
    final Job job = jobResult.getJob();
    logger.info( "Job {} is {}.", job.getId(), job.getStatus() );
    return new TranscodingJob( job.getId(), transcodeRequest.getInputPath(), transcodeRequest.getOutputPath() );
}
项目:s3_video    文件:AWSAdapter.java   
public CreateJobResult createTranscodeJob(String pipelineId, String inputKey) throws TranscodeException {
    JobInput input = new JobInput().withKey(inputKey);

    boolean isThumbnailConfigured = false;

    List<CreateJobOutput> hlsJobOutputs = new ArrayList<>();
    Iterator<String> hlsPresetKeys = hlsPresets.keySet().iterator();
    List<String> hlsJobKeys = new ArrayList<>();                
    while (hlsPresetKeys.hasNext()) {
        String hlsPresetKey = hlsPresetKeys.next();
        String hlsJobKey = "hls/" + hlsPresetKey;

        CreateJobOutput hlsJob = new CreateJobOutput()
        .withKey(hlsJobKey)
        .withPresetId((String)hlsPresets.get(hlsPresetKey))
        .withSegmentDuration(segmentDuration);

        if (!isThumbnailConfigured) {
            hlsJob.withThumbnailPattern(THUMBNAIL_PATTERN);
            isThumbnailConfigured = true;
        }

        hlsJobKeys.add(hlsJobKey);
        hlsJobOutputs.add(hlsJob);          
    }

    // Setup master playlist which can be used to play using adaptive bitrate.
    CreateJobPlaylist playlist = new CreateJobPlaylist()
        .withName("hls") 
        .withFormat("HLSv3")
        .withOutputKeys(hlsJobKeys);

    List<CreateJobOutput> webmJobOutputs = new ArrayList<>();
    Iterator<String> webmPresetKeys = webmPresets.keySet().iterator();
    while (webmPresetKeys.hasNext()) {
        String webmPresetKey = webmPresetKeys.next(); 
        CreateJobOutput webmJob = new CreateJobOutput()
        .withKey(webmPresetKey)
        .withPresetId((String)webmPresets.get(webmPresetKey));          

        if (!isThumbnailConfigured) {
            webmJob.withThumbnailPattern(THUMBNAIL_PATTERN);
            isThumbnailConfigured = true;
        }

        webmJobOutputs.add(webmJob);
    }

    List<CreateJobOutput> outputs = new ArrayList<>();
    outputs.addAll(hlsJobOutputs);
    outputs.addAll(webmJobOutputs);

    // Create the job.
    CreateJobRequest createJobRequest = new CreateJobRequest()
        .withPipelineId(pipelineId)
        .withInput(input)
        .withOutputKeyPrefix(inputKey + "/")
        .withOutputs(outputs)
        .withPlaylists(playlist);

    return transcoderClient.createJob(createJobRequest);
}
项目:openbd-core    文件:Create.java   
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
    AmazonKey amazonKey = getAmazonKey(_session, argStruct);
    AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

    CreateJobRequest cjr    = new CreateJobRequest();

    cjr.setPipelineId( getNamedStringParam(argStruct, "pipelineid", null) );
    if ( cjr.getPipelineId() == null || cjr.getPipelineId().isEmpty() )
        throwException(_session, "please provide a valid pipelineid");

    cjr.setOutputKeyPrefix( getNamedStringParam(argStruct, "outputkeyprefix", null) );
    if ( cjr.getOutputKeyPrefix() != null && cjr.getOutputKeyPrefix().isEmpty() )
        throwException(_session, "please provide a valid outputkeyprefix");


    // Handle the input
    cfStructData    input   = getNamedStructParam( _session, argStruct, "input", null );
    if ( input == null )
        throwException(_session, "please provide a 'input'");

    JobInput jobinput   = new JobInput();

    if ( input.containsKey("aspectratio") )
        jobinput.setAspectRatio( input.getData("aspectratio").getString() );

    if ( input.containsKey("container") )
        jobinput.setContainer( input.getData("container").getString() );

    if ( input.containsKey("framerate") )
        jobinput.setFrameRate( input.getData("framerate").getString() );

    if ( input.containsKey("interlaced") )
        jobinput.setInterlaced( input.getData("interlaced").getString() );

    if ( input.containsKey("key") )
        jobinput.setKey( input.getData("key").getString() );

    if ( input.containsKey("resolution") )
        jobinput.setResolution( input.getData("resolution").getString() );

    if ( input.containsKey("encryption") )
        jobinput.setEncryption( getEncryption( (cfStructData)input.getData("encryption") ) );

    cjr.setInput(jobinput);


    // Set the output
    cfArrayData outputArr   = getNamedArrayParam( _session, argStruct, "outputs", null );
    if ( outputArr == null )
        throwException(_session, "please provide 'outputs'");

    List<CreateJobOutput>   outputs = new LinkedList();
    for ( int x=0; x < outputArr.size(); x++ )
        outputs.add( getCreateJobOutput( (cfStructData)outputArr.getData(x+1) ) );

    cjr.setOutputs(outputs);


    // Now after collection all that; create the actual pipeline
    try{
        CreateJobResult cpres = et.createJob(cjr);
        return new cfStringData( cpres.getJob().getId() ); 
    }catch(Exception e){
        throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
        return cfBooleanData.TRUE;
    }
}