Search code examples
amazon-web-servicesaws-lambdaaws-sdkamazon-elastic-transcoder

How to set duration of the transcoded output file?


What is the correct way to specify 'duration' of the transcoded output in Amazon Elastic Transcoder? For example no matter how long the input video file, I would like to have a maximum of 3 minutes output.

I'm using a node.js lambda to kick off transcoder jobs. Looking at AWS.ElasticTranscoder, however, unable to determine a 'duration' parameter.

SegmentDuration seems similar but it appears to apply only to MPEG.


Solution

  • Consider using the TimeSpan map that is part of the Input parameters:

    Input: {
        AspectRatio: 'STRING_VALUE',
        Container: 'STRING_VALUE',
        DetectedProperties: {
          DurationMillis: 0,
          FileSize: 0,
          FrameRate: 'STRING_VALUE',
          Height: 0,
          Width: 0
        },
    <snip>
        Interlaced: 'STRING_VALUE',
        Key: 'STRING_VALUE',
        Resolution: 'STRING_VALUE',
        TimeSpan: {
          Duration: 'STRING_VALUE',
          StartTime: 'STRING_VALUE'
        }
    

    TimeSpan — (map) Settings for clipping an input. Each input can have different clip settings.

    StartTime — (String) The place in the input file where you want a clip to start. The format can be either HH:mm:ss.SSS (maximum value: 23:59:59.999; SSS is thousandths of a second) or sssss.SSS (maximum value: 86399.999). If you don't specify a value, Elastic Transcoder starts at the beginning of the input file.

    Duration — (String) The duration of the clip. The format can be either HH:mm:ss.SSS (maximum value: 23:59:59.999; SSS is thousandths of a second) or sssss.SSS (maximum value: 86399.999). If you don't specify a value, Elastic Transcoder creates an output file from StartTime to the end of the file.

    If you specify a value longer than the duration of the input file, Elastic Transcoder transcodes the file and returns a warning message.