Search code examples
amazon-web-servicesaws-lambdaamazon-elastic-transcoder

Reduce size and framerate of output GIFs from AWS Elastic Transcoder


I have a Lambda function setup that successfully creates an Elastic Transcoding job to transcode an m4v to a GIF. However, I need to reduce the file size of the ouptut GIF by both reducing the size of the content, and using fewer frames.

I have read through the documentation here: http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/preset-settings.html http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/create-job.html

but I can't find any settings that work for GIFs that will downscale the content or allow me to change the framerate.

I tried using Width, Height, and Resolution but they all gave me errors that said: UnexpectedParameter: Unexpected key

How can I change the size and framerate of the output?

Here is the code that runs successfully:

var params = {
  Input: { 
    Key: key
  },
  PipelineId: 'xxxx',
  Outputs: [
    {
      Key: outputKey(basename(key),'gif'),
      PresetId: '1351620000001-100200', // GIF (Animated)
      Composition: [
          {
              TimeSpan: {
                  Duration: '00:00:03.000'
              }
          }
      ]
    }
  ]
};

Solution

  • To change these settings, you need to create a new Preset

    1. Visit https://console.aws.amazon.com/elastictranscoder/home#presets:
    2. find the GIF (Animated) preset, select it and click 'Copy'
    3. Specify Width / Height / Bit Rate / Frame Rate in the Video section of your new custom preset
    4. update the PresetId value in your output to match your new preset's id