Search code examples
phpamazon-web-servicesamazon-s3amazon-elastic-transcoder

Add Cache-Control Metadata to AWS Elastic Transcoder Output


I am currently uploading a video to a S3 bucket and then using AWS Elastic Transcoder to create a webm file and to output a thumbnail. All of this is working except I am unable to set any metadata on the ET files.

I am attempting to add Cache-Control to both the webm and the thumbnail but I am unable to find anywhere in the PHP SDK that allows it.

I know I could do a S3 copyObject and add the metadata in that way but it seems very cumbersome.

Below is the code for my ET job Creation.

$result = $client->createJob(array(
    'PipelineId' => 'my-pipeline-id',
    'Input' => array(
        'Key' => $mp4Name,
        'FrameRate' => 'auto',
        'Resolution' => 'auto',
        'AspectRatio' => '16:9',
        'Interlaced' => 'auto',
        'Container' => 'mp4',
    ),
    'Outputs' => array(
        array(
            'Key' => $awsOutWebm,
            'ThumbnailPattern' => $thumbOut,
            'Rotate' => '0',
            'PresetId' => 'my-preset-id',
            'Watermarks' => array(
                array(
                    'PresetWatermarkId' => 'BottomRight',
                    'InputKey' => 'logo.png',
                ),
            ),
        ),
    ),
));

Solution

  • As far as I know, there isn't a way to tell Elastic Transcoder what headers you want to set to the output objects.

    A simple way I can think of to achieve what you are looking for is using a Lambda function. You may configure it to run on every successful transcoding (using SNS notifications) and set the headers on the output objects.