功能描述
CreateMediaTemplate 用于新增极速高清转码模板。
请求
请求示例
POST /template HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml<body>
说明
请求头
请求体
该请求操作的实现需要有如下请求体:
<Request><Tag>HighSpeedHd</Tag><Name>TemplateName</Name><Container><Format>mp4</Format></Container><Video><Codec>H.264</Codec><Bitrate>1000</Bitrate><Crf></Crf><Width>1280</Width><Height></Height><Fps>30</Fps><Gop></Gop><Bufsize>0</Bufsize><Maxrate>0</Maxrate></Video><Audio><Codec>aac</Codec><Samplerate>44100</Samplerate><Bitrate>128</Bitrate><Channels>4</Channels></Audio><TransConfig><IsCheckReso>false</IsCheckReso><ResoAdjMethod>1</ResoAdjMethod></TransConfig><TimeInterval><Start>0</Start><Duration>60</Duration></TimeInterval></Request>
具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Request | 无 | 保存请求的容器 | Container | 是 |
Container 类型 Request 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 | 限制 |
Tag | Request | 模板类型: HighSpeedHd | String | 是 | 无 |
Name | Request | 模板名称。仅支持中文、英文、数字、_、-和* | String | 是 | 无 |
Container | Request | 容器格式 | Container | 是 | 无 |
Video | Request | 视频信息 | Container | 是 | 无 |
TimeInterval | Request | 时间区间 | Container | 否 | 无 |
Audio | Request | 音频信息 | Container | 是 | 无 |
TransConfig | Request | 转码配置 | Container | 否 | 无 |
Container 类型 Container 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Format | Request.Container | 容器格式:mp4,flv,hls | String | 是 |
设定 Container,音频视频支持的格式如下表:
Container | Audio Codecs | Video Codecs |
mp4/hls | AAC、MP3 | H.264、H.265 |
flv | AAC、MP3 | H.264 |
Container 类型 Video 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 | 默认值 | 限制 |
Codec | Request.Video | 编解码格式 | String | 否 | H.264 | H.264、H.265 |
Width | Request.Video | 宽 | String | 否 | 视频原始宽度 | 1. 值范围:[128,4096] 2. 单位:px 3. 若只设置 Width 时,按照视频原始比例计算 Height 4. 必须为偶数 |
Height | Request.Video | 高 | String | 否 | 视频原始高度 | 1. 值范围:[128,4096] 2. 单位:px 3. 若只设置 Height 时,按照视频原始比例计算 Width 4. 必须为偶数 |
Fps | Request.Video | 帧率 | String | 否 | 无 | 1. 值范围:(0,60] 2. 单位:fps |
Bitrate | Request.Video | 视频输出文件的码率 | String | 否 | 无 | 1. 值范围:[10,50000] 2. 单位:Kbps |
Crf | Request.Video | 码率-质量控制因子 | String | 否 | 无 | 1. 值范围:(0,51] 2. 如果设置了 Crf,则 Bitrate 的设置失效 3. 当 Bitrate 为空时,默认为25 |
Gop | Request.Video | 关键帧间最大帧数 | String | 否 | 无 | 1. 值范围:[0,100000] |
Bufsize | Request.Video | 缓冲区大小 | String | 否 | 无 | 1. 值范围:[1000,128000] 2. 单位:Kb |
Maxrate | Request.Video | 视频码率峰值 | String | 否 | 无 | 1. 值范围:[10,50000] 2. 单位:Kbps |
HlsTsTime | Request.Video | hls 分片时间 | String | 否 | 5 | 1. (0 视频时长] 2. 单位为秒 |
Pixfmt | Request.Video | 视频颜色格式 | String | 否 | 无 | yuv420p |
LongShortMode | Request.Video | 长短边自适应 | String | 否 | false | true、false |
Container 类型 TimeInterval 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 | 默认值 | 限制 |
Start | Request.TimeInterval | 开始时间 | String | 否 | 无 | 1. [0 视频时长] 2. 单位为秒 3. 支持 float 格式,执行精度精确到毫秒 |
Duration | Request.TimeInterval | 持续时间 | String | 否 | 无 | 1. [0 视频时长] 2. 单位为秒 3. 支持 float 格式,执行精度精确到毫秒 |
Container 类型 Audio 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 | 默认值 | 限制 |
Codec | Request.Audio | 编解码格式 | String | 否 | aac | 取值 aac、mp3 |
Samplerate | Request.Audio | 采样率 | String | 否 | 44100 | 1. 单位:Hz 2. 可选 11025、22050、32000、44100、48000、96000 3. 不同的封装,mp3 支持不同的采样率,如下表所示 |
Bitrate | Request.Audio | 原始音频码率 | String | 否 | 无 | 1. 单位:Kbps 2. 值范围:[8,1000] |
Channels | Request.Audio | 声道数 | String | 否 | 无 | 1. 当 Codec 设置为 aac,支持1、2、4、5、6、8 2. 当 Codec 设置为 mp3,支持1、2 |
Y 表示支持这种采样率,N 表示不支持。
封装格式/音频采样率 | 11025 | 22050 | 32000 | 44100 | 48000 | 96000 |
flv | Y | Y | N | Y | N | N |
mp4 | N | Y | Y | Y | Y | N |
hls | Y | Y | Y | Y | Y | N |
Container 类型 TransConfig 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 | 默认值 | 限制 |
IsCheckReso | Request.TransConfig | 是否检查分辨率 | String | 否 | false | 1. true、false 2. 当为 false 时,按照配置参数转码 |
ResoAdjMethod | Request.TransConfig | 分辨率调整方式 | String | 否 | 0 | 1. 取值0、1;0 表示使用原视频分辨率;1表示返回转码失败 2. 当 IsCheckReso 为 true 时生效 |
IsHdr2Sdr | Request.TransConfig | 是否开启 HDR 转 SDR | String | 否 | false | true/false |
HlsEncrypt | Request.TransConfig | hls加密配置 | Container | 否 | 无 | 无 |
Container 类型 HlsEncrypt 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 必选 | 默认值 | 限制 |
IsHlsEncrypt | Request.TransConfig.HlsEncrypt | 是否开启HLS加密 | String | 否 | false | 1. true/false 2. 当 Container.Format 为 hls 时支持加密 |
UriKey | Request.TransConfig.HlsEncrypt | HLS加密的key | String | 否 | 无 | 当 IsHlsEncrypt 为 true 时,该参数才有意义 |
响应
响应头
响应体
该响应体返回为 application/xml 数据,包含完整节点数据的内容展示如下:
<Response><Template><Tag>HighSpeedHd</Tag><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><Name>TemplateName</Name><HighSpeedHd><Container><Format>mp4</Format></Container><Video><Codec>H.264</Codec><Bitrate>1000</Bitrate><Crf></Crf><Width>1280</Width><Height></Height><Fps>30</Fps><Gop></Gop><Bufsize>0</Bufsize><Maxrate>0</Maxrate></Video><Audio><Codec>aac</Codec><Samplerate>44100</Samplerate><Bitrate>128</Bitrate><Channels>4</Channels></Audio><TransConfig><IsCheckReso>false</IsCheckReso><ResoAdjMethod>1</ResoAdjMethod></TransConfig><TimeInterval><Start>0</Start><Duration>60</Duration></TimeInterval></HighSpeedHd><CreateTime>2020-08-05T11:35:24+0800</CreateTime><UpdateTime>2020-08-31T16:15:20+0800</UpdateTime></Template></Response>
具体的数据内容如下:
节点名称(关键字) | 父节点 | 描述 | 类型 |
Response | 无 | 保存结果的容器 | Container |
Container 节点 Response 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
TemplateId | Response.Template | 模板 ID | String |
Name | Response.Template | 模板名称 | String |
BucketId | Response.Template | 模板所属存储桶 | String |
Category | Response.Template | 模板属性,Custom 或者 Official | String |
Tag | Response.Template | 模板类型,HighSpeedHd | String |
UpdateTime | Response.Template | 更新时间 | String |
CreateTime | Response.Template | 创建时间 | String |
HighSpeedHd | Response.Template | 详细的模板参数 | Container |
Container 节点 HighSpeedHd 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
TimeInterval | Response.Template.HighSpeedHd | 同请求体中的 Request.TimeInterval | Container |
Container | Response.Template.HighSpeedHd | 同请求体中的 Request.Container | Container |
Video | Response.Template.HighSpeedHd | 同请求体中的 Request.Video | Container |
Audio | Response.Template.HighSpeedHd | 同请求体中的 Request.Audio | Container |
TransConfig | Response.Template.HighSpeedHd | 同请求体中的 Request.TransConfig | Container |
错误码
实际案例
请求
POST /template HTTP/1.1Authorization: q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0**********&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=28e9a4986df11bed0255e97ff90500557e0ea057Host: examplebucket-1250000000.ci.ap-beijing.myqcloud.comContent-Length: 1666Content-Type: application/xml<Request><Tag>HighSpeedHd</Tag><Name>TemplateName</Name><Container><Format>mp4</Format></Container><Video><Codec>H.264</Codec><Bitrate>1000</Bitrate><Crf></Crf><Width>1280</Width><Height></Height><Fps>30</Fps><Gop></Gop><Bufsize>0</Bufsize><Maxrate>0</Maxrate></Video><Audio><Codec>aac</Codec><Samplerate>44100</Samplerate><Bitrate>128</Bitrate><Channels>4</Channels></Audio><TransConfig><IsCheckReso>false</IsCheckReso><ResoAdjMethod>1</ResoAdjMethod></TransConfig><TimeInterval><Start>0</Start><Duration>60</Duration></TimeInterval></Request>
响应
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 100Connection: keep-aliveDate: Thu, 15 Jun 2017 12:37:29 GMTServer: tencent-cix-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****<Response><Template><Tag>HighSpeedHd</Tag><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><Name>TemplateName</Name><HighSpeedHd><Container><Format>mp4</Format></Container><Video><Codec>H.264</Codec><Bitrate>1000</Bitrate><Crf></Crf><Width>1280</Width><Height></Height><Fps>30</Fps><Gop></Gop><Bufsize>0</Bufsize><Maxrate>0</Maxrate></Video><Audio><Codec>aac</Codec><Samplerate>44100</Samplerate><Bitrate>128</Bitrate><Channels>4</Channels></Audio><TransConfig><IsCheckReso>false</IsCheckReso><ResoAdjMethod>1</ResoAdjMethod></TransConfig><TimeInterval><Start>0</Start><Duration>60</Duration></TimeInterval></HighSpeedHd><CreateTime>2020-08-05T11:35:24+0800</CreateTime><UpdateTime>2020-08-31T16:15:20+0800</UpdateTime></Template></Response>