

终止支持通知：2025 年 11 月 13 日， AWS 我们将停止对亚马逊 Elastic Transcoder 的支持。2025 年 11 月 13 日之后，您将无法再访问 Elastic Transcoder 控制台或 Elastic Transcoder 资源。

有关过渡到的更多信息 AWS Elemental MediaConvert，请访问此[博客文章](https://aws.amazon.com/blogs/media/how-to-migrate-workflows-from-amazon-elastic-transcoder-to-aws-elemental-mediaconvert/)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 创建预设
<a name="create-preset"></a>

**Topics**
+ [描述](#create-preset-description)
+ [请求](#create-preset-requests)
+ [响应](#create-preset-responses)
+ [错误](#create-preset-response-errors)
+ [示例](#create-preset-examples)

## 描述
<a name="create-preset-description"></a>

要创建预设，请向 `/2012-09-25/presets` 资源发送 POST 请求。

**重要**  
Elastic Transcoder 将检查您指定的设置，以确保设置符合 Elastic Transcoder 要求并确定设置是否符合适用标准。如果您的设置对于 Elastic Transcoder 无效，则 Elastic Transcoder 将返回 HTTP 400 响应 (`ValidationException`)，并且不会创建预设。如果设置对于 Elastic Transcoder 有效但未严格符合标准，则 Elastic Transcoder 将创建预设并在响应中返回一条警告消息。这有助于您确定设置是否符合标准，同时针对 Elastic Transcoder 生成的文件为您提供更高的灵活性。

**注意**  
Elastic Transcoder 包含几个用于常见输出格式的系统预设。有关更多信息，请参阅 **PresetId**主题中的 [创建作业](create-job.md)。

## 请求
<a name="create-preset-requests"></a>

### 语法
<a name="create-preset-request-syntax"></a>

```
POST /2012-09-25/presets HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: */*
Host: elastictranscoder.Elastic Transcoder endpoint.amazonaws.com:443
x-amz-date: 20130114T174952Z
Authorization: AWS4-HMAC-SHA256 
               Credential=AccessKeyID/request-date/Elastic Transcoder endpoint/elastictranscoder/aws4_request,
               SignedHeaders=host;x-amz-date;x-amz-target,
               Signature=calculated-signature
Content-Length: number of characters in the JSON string
{
   "Name":"preset name",
   "Description":"preset description",
   "Container":"flac|flv|fmp4|gif|mp2|mp3|mp4|mpg|mxf|oga|ogg|ts|wav|webm",
   "Audio":{
      "Codec":"AAC|flac|mp2|mp3|pcm|vorbis",
      "CodecOptions":{
          "Profile":"auto|AAC-LC|HE-AAC|HE-AACv2",
          "BitDepth":"8|16|24|32",
          "Signed":"Signed|Unsigned",
          "BitOrder":"LittleEndian"
      },
      "SampleRate":"auto|22050|32000|44100|48000|96000",
      "BitRate":"audio bit rate of output file in kilobits/second",
      "Channels":"auto|0|1|2",
      "AudioPackingMode":"SingleTrack|OneChannelPerTrack|
          OneChannelPerTrackWithMosTo8Tracks"
   },
   "Video":{
      "Codec":"gif|H.264|mpeg2|vp8|vp9",
      "CodecOptions":{
         "Profile":"baseline|main|high|0|1|2|3",
         "Level":"1|1b|1.1|1.2|1.3|2|2.1|2.2|3|3.1|3.2|4|4.1",
         "MaxReferenceFrames":"maximum number of reference frames",
         "MaxBitRate":"maximum bit rate",
         "BufferSize":"maximum buffer size",
         "InterlacedMode":"Progressive|TopFirst|BottomFirst|Auto",
         "ColorSpaceConversion":"None|Bt709ToBt601|Bt601ToBt709|Auto",
         "ChromaSubsampling":"yuv420p|yuv422p",
         "LoopCount":"Infinite|[0,100]"
      },
      "KeyframesMaxDist":"maximum frames between key frames",
      "FixedGOP":"true|false",
      "BitRate":"auto|video bit rate of output file in kilobits/second",
      "FrameRate":"auto|10|15|23.97|24|25|29.97|30|50|60",
      "MaxFrameRate":"10|15|23.97|24|25|29.97|30|50|60",
      "MaxWidth":"auto|[128,4096]",
      "MaxHeight":"auto|[96,3072]",
      "SizingPolicy":"Fit|Fill|Stretch|Keep|ShrinkToFit|ShrinkToFill",
      "PaddingPolicy":"Pad|NoPad",
      "DisplayAspectRatio":"auto|1:1|4:3|3:2|16:9",
      "Resolution":"auto|width in pixelsxheight in pixels" <not recommended>,
      "AspectRatio":"auto|1:1|4:3|3:2|16:9" <not recommended>,
      "Watermarks":[
         {
            "Id":"unique identifier up to 40 characters",
            "MaxWidth":"[16,Video:MaxWidth]px|[0,100]%",
            "MaxHeight":"[16,Video:MaxHeight]px|[0,100]%", 
            "SizingPolicy":"Fit|Stretch|ShrinkToFit",
            "HorizontalAlign":"Left|Right|Center",
            "HorizontalOffset":"[0,100]%|[0,Video:MaxWidth]px",
            "VerticalAlign":"Top|Bottom|Center",
            "VerticalOffset":"[0,100]%|[0,Video:MaxHeight]px",
            "Opacity":"[0,100]",
            "Target":"Content|Frame"
         },
         {...}
      ]
   },
   "Thumbnails":{
      "Format":"jpg|png",
      "Interval":"number of seconds between thumbnails",
      "MaxWidth":"auto|[32,4096]",
      "MaxHeight":"auto|[32,3072]",
      "SizingPolicy":"Fit|Fill|Stretch|Keep|ShrinkToFit|ShrinkToFill",
      "PaddingPolicy":"Pad|NoPad",
      "Resolution":"width in pixelsxheight in pixels" <not recommended>,
      "AspectRatio":"auto|1:1|4:3|3:2|16:9" <not recommended>
   }
}
```

### 请求参数
<a name="create-preset-request-parameters"></a>

此操作不使用请求参数。

### 请求标头
<a name="create-preset-request-headers"></a>

此操作仅使用所有操作通用的请求标头。有关通用请求标头的信息，请参阅 [HTTP 标头内容](making-http-requests.md#http-request-header)。

### 请求正文
<a name="create-preset-request-body"></a>

请求正文中的 JSON 字符串包含 `CreatePreset` 操作的输入对象。有关输入对象的更多信息，请参阅 [您在创建 Elastic Transcoder 预设时指定的设置](preset-settings.md)。

## 响应
<a name="create-preset-responses"></a>

### 语法
<a name="create-preset-response-syntax"></a>

```
Status: 201 Created
x-amzn-RequestId: c321ec43-378e-11e2-8e4c-4d5b971203e9
Content-Type: application/json
Content-Length: number of characters in the response
Date: Mon, 14 Jan 2013 06:01:47 GMT
{
   "Preset":{
      "Id":"Id for the new preset",
      "Type":"Custom|System",
      "Name":"preset name",
      "Description":"preset description",
      "Container":"flac|flv|fmp4|gif|mp2|mp3|mp4|mpg|mxf|oga|ogg|ts|wav|webm",
      "Audio":{
         "Codec":"AAC|flac|mp2|mp3|pcm|vorbis",
         "CodecOptions":{
            "Profile":"auto|AAC-LC|HE-AAC|HE-AACv2",
            "BitDepth":"8|16|24|32",
            "Signed":"Signed|Unsigned",
            "BitOrder":"LittleEndian"
         },
         "SampleRate":"auto|22050|32000|44100|48000|96000",
         "BitRate":"audio bit rate of output file in kilobits/second",
         "Channels":"auto|0|1|2",
         "AudioPackingMode":"SingleTrack|OneChannelPerTrack|
            OneChannelPerTrackWithMosTo8Tracks"
      },
      "Video":{
         "Codec":"gif|H.264|mpeg2|vp8|vp9",
         "CodecOptions":{
            "Profile":"baseline|main|high|0|1|2|3",
            "Level":"1|1b|1.1|1.2|1.3|2|2.1|2.2|3|3.1|3.2|4|4.1",
            "MaxReferenceFrames":maximum number of reference frames,
            "MaxBitRate":"maximum bit rate",
            "BufferSize":"maximum buffer size",
            "InterlacedMode":"Progressive|TopFirst|BottomFirst|Auto",
            "ColorSpaceConversionMode":"None|Bt709ToBt601|Bt601ToBt709|Auto",
            "ChromaSubsampling":"yuv420p|yuv422p",
            "LoopCount":"Infinite|[0,100]"
         },
         "KeyframesMaxDist":maximum frames between key frames,
         "FixedGOP":"true|false",
         "BitRate":"auto|video bit rate of output file in kilobits/second",
         "FrameRate":"auto|10|15|23.97|24|25|29.97|30|50|60",
         "MaxFrameRate":"10|15|23.97|24|25|29.97|30|50|60",
         "MaxWidth":"auto|[128,4096]",
         "MaxHeight":"auto|[96,3072]",
         "SizingPolicy":"Fit|Fill|Stretch|Keep|ShrinkToFit|ShrinkToFill",
         "PaddingPolicy":"Pad|NoPad",
         "DisplayAspectRatio":"auto|1:1|4:3|3:2|16:9",
         "Resolution":"width in pixelsxheight in pixels" <not recommended>,
         "AspectRatio":"auto|1:1|4:3|3:2|16:9" <not recommended>
         "Watermarks":[
            {
               "Id":"unique identifier up to 40 characters",
               "MaxWidth":"[16,Video:MaxWidth]px|[0,100]%",
               "MaxHeight":"[16,Video:MaxHeight]px|[0,100]%", 
               "SizingPolicy":"Fit|Stretch|ShrinkToFit",
               "HorizontalAlign":"Left|Right|Center",
               "HorizontalOffset":"[0,100]%|[0,Video:MaxWidth]px",
               "VerticalAlign":"Top|Bottom|Center",
               "VerticalOffset":"[0,100]%|[0,Video:MaxHeight]px",
               "Opacity":"[0,100]",
               "Target":"Content|Frame"
            }
         ]
      },   
      "Thumbnails":{
         "Format":"jpg|png",
         "Interval":"number of seconds between thumbnails",
         "MaxWidth":"auto|[32,4096]",
         "MaxHeight":"auto|[32,3072]",
         "SizingPolicy":"Fit|Fill|Stretch|Keep|ShrinkToFit|ShrinkToFill",
         "PaddingPolicy":"Pad|NoPad",
         "Resolution":"width in pixelsxheight in pixels",
         "AspectRatio":"auto|1:1|4:3|3:2|16:9"
      }
   },
   "Warning":"message about codec compatibility"
}
```

### 响应标头
<a name="create-preset-response-headers"></a>

此操作仅使用大多数响应通用的响应标头。有关通用响应标头的信息，请参阅 [HTTP 响应](making-http-requests.md#http-response-header)。

### 响应正文
<a name="create-preset-response-body"></a>

创建任务时，Elastic Transcoder 将返回在请求中指定的值。有关更多信息，请参阅 [请求正文](#create-preset-request-body)。

此外，Elastic Transcoder 将返回以下值。

**（自动）Id**  
新预设的标识符。您使用该值获取预设的设置或将其删除。

**（自动）Type**  
该预设是 Elastic Transcoder (`System`) 提供的默认预设还是您定义的预设 (`Custom`)。

**（自动）Warning**  
当预设的设置不符合**编解码器**的标准，但这些设置可能产生可接受的输出时，Elastic Transcoder 会创建预设并包含一条警告，说明预设设置为何不兼容。

## 错误
<a name="create-preset-response-errors"></a>

有关 Elastic Transcoder 异常和错误消息的信息，请参阅 [处理 Elastic Transcoder 中的错误](error-handling.md)。

## 示例
<a name="create-preset-examples"></a>

以下示例请求创建了一个名为的预设 DefaultPreset。

### 示例请求
<a name="create-preset-examples-sample-request"></a>

```
POST /2012-09-25/presets HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: */*
Host: elastictranscoder.Elastic Transcoder endpoint.amazonaws.com:443
x-amz-date: 20130114T174952Z
Authorization: AWS4-HMAC-SHA256 
               Credential=AccessKeyID/request-date/Elastic Transcoder endpoint/elastictranscoder/aws4_request,
               SignedHeaders=host;x-amz-date;x-amz-target,
               Signature=calculated-signature
Content-Length: number of characters in the JSON string
{
   "Name":"DefaultPreset",
   "Description":"Use for published videos",
   "Container":"mp4",
   "Audio":{
      "Codec":"AAC",
      "CodecOptions":{
         "Profile":"AAC-LC"
      },
      "SampleRate":"44100",
      "BitRate":"96",
      "Channels":"2"
   },
   "Video":{
      "Codec":"H.264",
      "CodecOptions":{
         "Profile":"main",
         "Level":"2.2",
         "MaxReferenceFrames":"3",
         "MaxBitRate":"",
         "BufferSize":"",
         "InterlacedMode":"Progressive",
         "ColorSpaceConversionMode":"None"
      },
      "KeyframesMaxDist":"240",
      "FixedGOP":"false",
      "BitRate":"1600",
      "FrameRate":"auto",
      "MaxFrameRate":"30",
      "MaxWidth":"auto",
      "MaxHeight":"auto",
      "SizingPolicy":"Fit",
      "PaddingPolicy":"Pad",
      "DisplayAspectRatio":"auto",
      "Watermarks":[
         {
            "Id":"company logo",
            "MaxWidth":"20%",
            "MaxHeight":"20%", 
            "SizingPolicy":"ShrinkToFit",
            "HorizontalAlign":"Right",
            "HorizontalOffset":"10px",
            "VerticalAlign":"Bottom",
            "VerticalOffset":"10px",
            "Opacity":"55.5",
            "Target":"Content"
         }
      ]
   },
   "Thumbnails":{
      "Format":"png",
      "Interval":"120",
      "MaxWidth":"auto",
      "MaxHeight":"auto",
      "SizingPolicy":"Fit",
      "PaddingPolicy":"Pad"
   }
}
```

### 示例响应
<a name="create-preset-examples-sample-response"></a>

```
Status: 201 Created
x-amzn-RequestId: c321ec43-378e-11e2-8e4c-4d5b971203e9
Content-Type: application/json
Content-Length: number of characters in the response
Date: Mon, 14 Jan 2013 06:01:47 GMT

{
   "Preset":{
      "Id":"5555555555555-abcde5",
      "Type":"Custom",
      "Name":"DefaultPreset",
      "Description":"Use for published videos",
      "Container":"mp4",
      "Audio":{
         "Codec":"AAC",
         "CodecOptions":{
            "Profile":"AAC-LC"
         },
         "SampleRate":"44100",
         "BitRate":"96",
         "Channels":"2"
      },
      "Video":{
         "Codec":"H.264",
         "CodecOptions":{
            "Profile":"main",
            "Level":"2.2",
            "MaxReferenceFrames":"3",
            "MaxBitRate":"",
            "BufferSize":"",
            "InterlacedMode":"Progressive",
            "ColorSpaceConversionMode":"None|Bt709ToBt601|Bt601ToBt709|Auto"
         },
         "KeyframesMaxDist":"240",
         "FixedGOP":"false",
         "BitRate":"1600",
         "FrameRate":"auto",
         "MaxFrameRate":"30",
         "MaxWidth":"auto",
         "MaxHeight":"auto",
         "SizingPolicy":"Fit",
         "PaddingPolicy":"Pad",
         "DisplayAspectRatio":"auto",
         "Watermarks":[
            {
               "Id":"company logo",
               "MaxWidth":"20%",
               "MaxHeight":"20%", 
               "SizingPolicy":"ShrinkToFit",
               "HorizontalAlign":"Right",
               "HorizontalOffset":"10px",
               "VerticalAlign":"Bottom",
               "VerticalOffset":"10px",
               "Opacity":"55.5",
               "Target":"Content"
            }
         ]
      },
      "Thumbnails":{
         "Format":"png",
         "Interval":"120",
         "MaxWidth":"auto",
         "MaxHeight":"auto",
         "SizingPolicy":"Fit",
         "PaddingPolicy":"Pad"
      }
   },
   "Warning":""
}
```