Unable to set an output duration with the Elastic Transcoder Ruby SDK

675 views Asked by At

Using version 1.22.1 of the Ruby SDK I'm unable to set a duration on the output of a video being transcoded by the Elastic Transcoder. Based on the docs it looks like the outputs hash needs a composition array/hash containing a time_span hash with the duration. In my case I'm trying to limit it to 10 seconds.

Code sample:

transcoder = AWS::ElasticTranscoder::Client.new(
      access_key_id: ENV['S3_ACCESS_KEY_ID'],
      secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
      region: ENV['AET_REGION']
    )

    transcoder.create_job(
      pipeline_id: ENV['AET_PIPELINE_ID'],
      input: {
        key: "#{video.s3_key}",
        frame_rate: 'auto',
        resolution: 'auto',
        aspect_ratio: 'auto',
        interlaced: 'auto',
        container: 'auto'
      },
      output: {
        key: "#{video.s3_key}/web.mp4",
        preset_id: '1351620000001-100070', # System preset: Web
        composition: [
          {
            time_span: {
              duration: '00:00:10.000'
            }
          }
        ]
      }
    )

Here's the error I get:

unexpected option :composition

Here's a link to the Ruby SDK docs on the transcoder: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElasticTranscoder/Client.html#create_job-instance_method

And here are the general AWS Elastic Transcoder docs: http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/create-job.html

I'm hoping this is a syntax error and wasn't just left out of the SDK.

edit: Updated code to include initialization and composition snippet from Loren.

1

There are 1 answers

5
Loren Segal On BEST ANSWER

From the commit history, it looks like :composition was only added in v1.25.0 of the SDK. The documentation published on the site only reflects the latest version of the SDK. If you update to the latest version, you should be able to use this parameter. Note however that it is documented as an array of hashes, so you will have to wrap your composition structure in an array of hashes:

composition: [{time_span: {duration: '...'}}]