Search in sources :

Example 1 with AWSMediaConvert

use of com.amazonaws.services.mediaconvert.AWSMediaConvert in project studio by craftercms.

the class AwsMediaConvertServiceImpl method uploadVideo.

/**
 * {@inheritDoc}
 */
@Override
@HasPermission(type = DefaultPermission.class, action = "s3 write")
public MediaConvertResult uploadVideo(@ValidateStringParam @ProtectedResourceId("siteId") final String site, @ValidateStringParam final String inputProfileId, @ValidateStringParam final String outputProfileId, @ValidateStringParam final String filename, final InputStream content) throws AwsException {
    MediaConvertProfile profile = getProfile(site, inputProfileId);
    AmazonS3 s3Client = getS3Client(profile);
    AWSMediaConvert mediaConvertClient = getMediaConvertClient(profile);
    logger.info("Starting upload of file {0} for site {1}", filename, site);
    AwsUtils.uploadStream(profile.getInputPath(), filename, s3Client, partSize, filename, content);
    logger.info("Upload of file {0} for site {1} complete", filename, site);
    String originalName = FilenameUtils.getBaseName(filename);
    JobTemplate jobTemplate = mediaConvertClient.getJobTemplate(new GetJobTemplateRequest().withName(profile.getTemplate())).getJobTemplate();
    JobSettings jobSettings = new JobSettings().withInputs(new Input().withFileInput(AwsUtils.getS3Url(profile.getInputPath(), filename)));
    CreateJobRequest createJobRequest = new CreateJobRequest().withJobTemplate(profile.getTemplate()).withSettings(jobSettings).withRole(profile.getRole()).withQueue(profile.getQueue());
    logger.info("Starting transcode job of file {0} for site {1}", filename, site);
    CreateJobResult createJobResult = mediaConvertClient.createJob(createJobRequest);
    logger.debug("Job {0} started", createJobResult.getJob().getArn());
    return buildResult(jobTemplate, createJobResult, outputProfileId, originalName);
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) AWSMediaConvert(com.amazonaws.services.mediaconvert.AWSMediaConvert) Input(com.amazonaws.services.mediaconvert.model.Input) CreateJobResult(com.amazonaws.services.mediaconvert.model.CreateJobResult) JobSettings(com.amazonaws.services.mediaconvert.model.JobSettings) MediaConvertProfile(org.craftercms.studio.api.v1.aws.mediaconvert.MediaConvertProfile) GetJobTemplateRequest(com.amazonaws.services.mediaconvert.model.GetJobTemplateRequest) JobTemplate(com.amazonaws.services.mediaconvert.model.JobTemplate) CreateJobRequest(com.amazonaws.services.mediaconvert.model.CreateJobRequest) HasPermission(org.craftercms.commons.security.permissions.annotations.HasPermission)

Example 2 with AWSMediaConvert

use of com.amazonaws.services.mediaconvert.AWSMediaConvert in project studio by craftercms.

the class MediaConvertImpl method startJob.

/**
 * {@inheritDoc}
 */
@Override
public MediaConvertJob startJob(final String filename, final InputStream content, final MediaConvertProfile profile) throws AwsException {
    AmazonS3 s3Client = getS3Client(profile);
    AWSMediaConvert mediaConvertClient = getMediaConvertClient(profile);
    AwsUtils.uploadStream(profile.getInputPath(), filename, s3Client, partSize, filename, content);
    String key = FilenameUtils.getBaseName(filename);
    JobTemplate jobTemplate = mediaConvertClient.getJobTemplate(new GetJobTemplateRequest().withName(profile.getTemplate())).getJobTemplate();
    JobSettings jobSettings = new JobSettings().withInputs(new Input().withFileInput(AwsUtils.getS3Url(profile.getInputPath(), filename)));
    CreateJobRequest createJobRequest = new CreateJobRequest().withJobTemplate(profile.getTemplate()).withSettings(jobSettings).withRole(profile.getRole()).withQueue(profile.getQueue());
    CreateJobResult createJobResult = mediaConvertClient.createJob(createJobRequest);
    return createMediaConverJob(createJobResult, getJobDestination(jobTemplate), key);
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) AWSMediaConvert(com.amazonaws.services.mediaconvert.AWSMediaConvert) Input(com.amazonaws.services.mediaconvert.model.Input) CreateJobResult(com.amazonaws.services.mediaconvert.model.CreateJobResult) JobSettings(com.amazonaws.services.mediaconvert.model.JobSettings) GetJobTemplateRequest(com.amazonaws.services.mediaconvert.model.GetJobTemplateRequest) JobTemplate(com.amazonaws.services.mediaconvert.model.JobTemplate) CreateJobRequest(com.amazonaws.services.mediaconvert.model.CreateJobRequest)

Aggregations

AWSMediaConvert (com.amazonaws.services.mediaconvert.AWSMediaConvert)2 CreateJobRequest (com.amazonaws.services.mediaconvert.model.CreateJobRequest)2 CreateJobResult (com.amazonaws.services.mediaconvert.model.CreateJobResult)2 GetJobTemplateRequest (com.amazonaws.services.mediaconvert.model.GetJobTemplateRequest)2 Input (com.amazonaws.services.mediaconvert.model.Input)2 JobSettings (com.amazonaws.services.mediaconvert.model.JobSettings)2 JobTemplate (com.amazonaws.services.mediaconvert.model.JobTemplate)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 HasPermission (org.craftercms.commons.security.permissions.annotations.HasPermission)1 MediaConvertProfile (org.craftercms.studio.api.v1.aws.mediaconvert.MediaConvertProfile)1