Search in sources :

Example 1 with MediaConvertProfile

use of org.craftercms.studio.api.v1.aws.mediaconvert.MediaConvertProfile 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 MediaConvertProfile

use of org.craftercms.studio.api.v1.aws.mediaconvert.MediaConvertProfile in project studio by craftercms.

the class MediaConvertProfileMapper method mapProfile.

@Override
protected MediaConvertProfile mapProfile(HierarchicalConfiguration<ImmutableNode> profileConfig) throws ConfigurationException {
    MediaConvertProfile profile = super.mapProfile(profileConfig);
    // For MediaConvert the endpoint is required
    profile.setEndpoint(getRequiredStringProperty(profileConfig, CONFIG_KEY_ENDPOINT));
    profile.setRole(getRequiredStringProperty(profileConfig, CONFIG_KEY_ROLE));
    profile.setQueue(getRequiredStringProperty(profileConfig, CONFIG_KEY_QUEUE));
    profile.setTemplate(getRequiredStringProperty(profileConfig, CONFIG_KEY_TEMPLATE));
    profile.setInputPath(getRequiredStringProperty(profileConfig, CONFIG_KEY_INPUT_PATH));
    return profile;
}
Also used : MediaConvertProfile(org.craftercms.studio.api.v1.aws.mediaconvert.MediaConvertProfile)

Aggregations

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