简介
本文档提供关于极速高清转码模板接口的 API 概览和 SDK 示例代码。
API | 操作描述 |
用于新增极速高清转码模板。 | |
用于更新极速高清转码模板。 |
新增极速高清转码模板
功能说明
用于新增极速高清转码模板。
方法原型
public Guzzle\\Service\\Resource\\Model createMediaHighSpeedHdTemplate(array $args = array());
请求示例
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的 region 可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', //协议头部,默认为 http'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {// https://cloud.tencent.com/document/product/436/58307 新增极速高清转码模板$result = $cosClient->createMediaHighSpeedHdTemplate(array('Bucket' => 'examplebucket-125000000', //存储桶名称,由 BucketName-Appid 组成,可以在 COS 控制台查看 https://console.cloud.tencent.com/cos5/bucket'Tag' => 'HighSpeedHd','Name' => 'HighSpeedHd-Template-Name','Container' => array('Format' => '',),'Video' => array('Codec' => '','Width' => '','Height' => '','Fps' => '','Profile' => '','Bitrate' => '','Crf' => '','Gop' => '','Preset' => '','Bufsize' => '','Maxrate' => '','HlsTsTime' => '','Pixfmt' => '',),'TimeInterval' => array('Start' => '','Duration' => '',),'Audio' => array('Codec' => '','Samplerate' => '','Bitrate' => '','Channels' => '',),'TransConfig' => array('IsCheckReso' => '','ResoAdjMethod' => '','IsHdr2Sdr' => '',),));// 请求成功print_r($result);} catch (\\Exception $e) {// 请求失败echo($e);}
参数说明
Request 中的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Tag | Request | 模板类型: HighSpeedHd | String | 是 |
Name | Request | 模板名称。仅支持中文、英文、数字、_、-和*,长度不超过 64 | String | 是 |
Container | Request | 容器格式 | Container | 是 |
Video | Request | 视频信息 | Container | 是 |
TimeInterval | Request | 时间区间 | Container | 否 |
Audio | Request | 音频信息 | Container | 否 |
TransConfig | Request | 转码配置 | Container | 否 |
说明:
不传 Audio,相当于删除音频信息。
Container 类型
Container
的具体数据描述如下:节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Format | Request.Container | 封装格式: mp4,flv,hls,mkv | String | 是 |
ClipConfig | Request.Container | 分片配置, 当 Format 为 hls 时有效 | Container | 否 |
Container 类型 ClipConfig 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Duration | Request.Container.ClipConfig | 分片时长, 默认5s | String | 否 |
设定 container,音频视频支持的格式如下表:
Container | Audio Codecs | Video Codecs |
mp4/hls/mkv | AAC、MP3 | H.264、H.265 |
flv | AAC、MP3 | H.264 |
Container 类型
Video
的具体数据描述如下:节点名称(关键字) | 父节点 | 描述 | 类型 | 默认值 | 是否必选 |
Codec | Request.Video | 编解码格式 H.264 H.265 | String | H.264 | 否 |
Width | Request.Video | 宽 值范围:[128,4096] 单位:px 若只设置 Width 时,按照视频原始比例计算 Height 必须为偶数 | String | 视频原始宽度 | 否 |
Height | Request.Video | 高 值范围:[128,4096] 单位:px 若只设置 Height 时,按照视频原始比例计算 Width 必须为偶数 | String | 视频原始高度 | 否 |
Fps | Request.Video | 帧率 值范围:(0,60] 单位:fps | String | 无 | 否 |
Profile | Request.Video | 编码级别 支持 baseline、main、high baseline:适合移动设备; main:适合标准分辨率设备; high:适合高分辨率设备; 仅H.264支持此参数。 | String | high | 否 |
Bitrate | Request.Video | 视频输出文件的码率 值范围:[10,50000],单位:Kbps auto 表示自适应码率 | String | 无 | 否 |
Crf | Request.Video | 码率-质量控制因子 值范围:(0,51] 如果设置了 Crf,则 Bitrate 的设置失效 当 Bitrate 为空时,默认为25 | String | 无 | 否 |
Gop | Request.Video | 关键帧间最大帧数,值范围:[0, 100000] | String | 无 | 否 |
Preset | Request.Video | 视频算法器预置 仅H.264支持该参数 取值 veryfast、fast、medium、slow、slower | String | medium | 否 |
Bufsize | Request.Video | 缓冲区大小 值范围:[1000,128000] 单位:Kb | String | 无 | 否 |
Maxrate | Request.Video | 视频码率峰值 值范围:[10,50000] 单位:Kbps | String | 无 | 否 |
Pixfmt | Request.Video | 视频颜色格式 H.264支持:yuv420p、auto H.265支持:yuv420p、yuv420p10le、auto | String | 无 | 否 |
Rotate | Request.Video | 旋转角度 值范围:[0, 360) 单位:度 | String | 无 | 否 |
Roi | Request.Video | Roi 强度,取值 none、low、medium、high | String | none | 否 |
Container 类型
TimeInterval
的具体数据描述如下:节点名称(关键字) | 父节点 | 描述 | 类型 | 默认值 | 是否必选 |
Start | Request.TimeInterval | 开始时间 [0 视频时长] 单位为秒 支持 float 格式,执行精度精确到毫秒 | String | 无 | 否 |
Duration | Request.TimeInterval | 持续时间 [0 视频时长] 单位为秒 支持 float 格式,执行精度精确到毫秒 | String | 无 | 否 |
Container 类型
Audio
的具体数据描述如下:节点名称(关键字) | 父节点 | 描述 | 类型 | 默认值 | 是否必选 |
Codec | Request.Audio | 编解码格式,取值 aac、mp3 | String | aac | 否 |
Samplerate | Request.Audio | 采样率 单位:Hz 可选11025、22050、32000、44100、48000、96000 不同的封装,mp3支持不同的采样率,如下表所示 | String | 44100 | 否 |
Bitrate | Request.Audio | 原始音频码率 单位:Kbps 值范围:[8,1000] | String | 无 | 否 |
Channels | Request.Audio | 声道数 当 Codec 设置为 aac,支持1、2、4、5、6、8 当 Codec 设置为 mp3,支持1、2 | String | 无 | 否 |
Remove | Request.Audio | 是否删除源音频流,取值 true、false | String | false | 否 |
说明
Y 表示支持这种采样率,N 表示不支持。
封装格式/音频采样率 | 11025 | 22050 | 32000 | 44100 | 48000 | 96000 |
flv | N | Y | N | Y | N | N |
mp4 | N | Y | Y | Y | Y | N |
hls/mkv | Y | Y | Y | Y | Y | N |
Container 类型
TransConfig
的具体数据描述如下:节点名称(关键字) | 父节点 | 描述 | 类型 | 默认值 | 是否必选 |
AdjDarMethod | Request.TransConfig | 分辨率调整方式 取值 scale、crop、pad、none 当输出视频的宽高比与原视频不等时,根据此参数做分辨率的相应调整 | String | none | 否 |
IsCheckReso | Request.TransConfig | 是否检查分辨率,取值 true、false 当为 false 时,按照配置参数转码 | String | false | 否 |
ResoAdjMethod | Request.TransConfig | 分辨率调整方式 当 IsCheckReso 为 true 时生效,取值0、1; 0 表示使用原视频分辨率; 1 表示返回转码失败 | String | 0 | 否 |
IsCheckVideoBitrate | Request.TransConfig | 是否检查视频码率,取值 true、false 当为 false 时,按照配置参数转码 | String | false | 否 |
VideoBitrateAdjMethod | Request.TransConfig | 视频码率调整方式 IsCheckVideoBitrate 为 true 时生效,取值0、1; 当输出视频码率大于原视频码率时,0表示使用原视频码率;1表示返回转码失败 | String | 0 | 否 |
IsCheckAudioBitrate | Request.TransConfig | 是否检查音频码率,取值 true、false 当为 false 时,按照配置参数转码 | String | false | 否 |
AudioBitrateAdjMethod | Request.TransConfig | 音频码率调整方式 IsCheckAudioBitrate 为 true 时生效,取值0、1; 当输出音频码率大于原音频码率时,0表示使用原音频码率;1表示返回转码失败 | String | 0 | 否 |
IsCheckVideoFps | Request.TransConfig | 是否检查视频帧率,取值 true、false 当为 false 时,按照配置参数转码 | String | false | 否 |
VideoFpsAdjMethod | Request.TransConfig | 视频帧率调整方式 IsCheckVideoFps 为 true 时生效,取值0、1; 当输出视频帧率大于原视频帧率时,0表示使用原视频帧率;1表示返回转码失败 | String | 0 | 否 |
DeleteMetadata | Request.TransConfig | 是否删除文件中的 MetaData 信息,取值 true、false | String | false | 否 |
IsHdr2Sdr | Request.TransConfig | 是否开启 HDR 转 SDR,取值 true、false | String | false | 否 |
HlsEncrypt | Request.TransConfig | hls 加密配置 | Container | 无 | 无 |
AdjDarMethod 参数图示:


Container 类型 HlsEncrypt 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 | 默认值 |
IsHlsEncrypt | Request.TransConfig.HlsEncrypt | 是否开启 HLS 加密,取值 true/false | String | 否 | false |
UriKey | Request.TransConfig.HlsEncrypt | HLS 加密的 key,当 IsHlsEncrypt 为 true 时, 该参数才有意义 | String | 否 | 无 |
返回结果示例
GuzzleHttp\\Command\\Result Object([Body] => GuzzleHttp\\Psr7\\Stream Object([stream:GuzzleHttp\\Psr7\\Stream:private] => Resource id #88[size:GuzzleHttp\\Psr7\\Stream:private] =>[seekable:GuzzleHttp\\Psr7\\Stream:private] => 1[readable:GuzzleHttp\\Psr7\\Stream:private] => 1[writable:GuzzleHttp\\Psr7\\Stream:private] => 1[uri:GuzzleHttp\\Psr7\\Stream:private] => php://temp[customMetadata:GuzzleHttp\\Psr7\\Stream:private] => Array())[RequestId] => NjJhODQ2ZDJfNzgwYzdAJSIODJIAODJhMzk=[ContentType] => application/xml[ContentLength] => 1990[Bucket] => examplebucket-125000000[Location] => examplebucket-125000000.ci.ap-guangzhou.myqcloud.com/template[Response] => Array([RequestId] => NjJhODQ2ZDJfNzgwYzdAJSIODJIAODJhMzk=[Template] => Array([TemplateId] => t1a1c25825ded1zx8c09zx8c04007ac[Name] => HighSpeedHd-Template-Name[State] => Normal[Tag] => HighSpeedHd[CreateTime] => 2022-06-14T16:29:06+0800[UpdateTime] => 2022-06-14T16:29:06+0800[BucketId] => examplebucket-125000000[Category] => Custom[HighSpeedHd] => Array([Container] => Array([Format] => hls[ClipConfig] => Array([Duration] => 30))[Video] => Array([Codec] => H.264[Profile] => main[Bitrate] => 300[Crf] => 25[Width] => 400[Height] => 400[Fps] => 30[Gop] => 300[Preset] => veryfast[Bufsize] => 1000[Maxrate] => 300[Remove] => false[HlsTsTime] => 30[Pixfmt] => yuv420p[LongShortMode] => false)[Audio] => Array([Codec] => aac[Samplerate] => 11025[Bitrate] => 88[Channels] => 2[Remove] => false[KeepTwoTracks] => false[SwitchTrack] => false)[TransConfig] => Array([IsCheckReso] => true[IsCheckVideoBitrate] => false[IsCheckAudioBitrate] => false[ResoAdjMethod] => 0[VideoBitrateAdjMethod] => 0[AudioBitrateAdjMethod] => 0[AdjDarMethod] => none[IsStreamCopy] => false[DeleteMetadata] => false[IsHdr2Sdr] => true)[TimeInterval] => Array([Start] => 0[Duration] => 30)))))
更新极速高清转码模板
功能说明
用于更新极速高清转码模板。
方法原型
public Guzzle\\Service\\Resource\\Model updateMediaHighSpeedHdTemplate(array $args = array());
请求示例
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的 region 可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', //协议头部,默认为http'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {// https://cloud.tencent.com/document/product/436/58310 更新极速高清转码模板$result = $cosClient->updateMediaHighSpeedHdTemplate(array('Bucket' => 'examplebucket-125000000', //存储桶名称,由 BucketName-Appid 组成,可以在 COS 控制台查看 https://console.cloud.tencent.com/cos5/bucket'Key' => '', // TemplateId'Tag' => 'HighSpeedHd','Name' => 'HighSpeedHd-Template-Name','Container' => array('Format' => '',),'Video' => array('Codec' => '','Width' => '','Height' => '','Fps' => '','Profile' => '','Bitrate' => '','Crf' => '','Gop' => '','Preset' => '','Bufsize' => '','Maxrate' => '','HlsTsTime' => '','Pixfmt' => '',),'TimeInterval' => array('Start' => '','Duration' => '',),'Audio' => array('Codec' => '','Samplerate' => '','Bitrate' => '','Channels' => '',),'TransConfig' => array('IsCheckReso' => '','ResoAdjMethod' => '','IsHdr2Sdr' => '',),));// 请求成功print_r($result);} catch (\\Exception $e) {// 请求失败echo($e);}
参数说明
Request 中的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Key | 无 | 模版 ID | String | 是 |
Request | 无 | Container | 是 |
返回结果示例
GuzzleHttp\\Command\\Result Object([Body] => GuzzleHttp\\Psr7\\Stream Object([stream:GuzzleHttp\\Psr7\\Stream:private] => Resource id #88[size:GuzzleHttp\\Psr7\\Stream:private] =>[seekable:GuzzleHttp\\Psr7\\Stream:private] => 1[readable:GuzzleHttp\\Psr7\\Stream:private] => 1[writable:GuzzleHttp\\Psr7\\Stream:private] => 1[uri:GuzzleHttp\\Psr7\\Stream:private] => php://temp[customMetadata:GuzzleHttp\\Psr7\\Stream:private] => Array())[RequestId] => NjJhODQ4MTBfZmNjYTNiAJHIOSDJAOIDxMTliZjM=[ContentType] => application/xml[ContentLength] => 1992[Key] => t1a1c25825dedb4as8d90a8d09007ac[Bucket] => examplebucket-125000000[Location] => examplebucket-125000000.ci.ap-guangzhou.myqcloud.com/template/t1a1c25825dedb4as8d90a8d09007ac[Response] => Array([RequestId] => NjJhODQ4MTBfZmNjYTNiAJHIOSDJAOIDxMTliZjM=[Template] => Array([TemplateId] => t1a1c25825dedb4as8d90a8d09007ac[Name] => HighSpeedHd-Template-Name[State] => Normal[Tag] => HighSpeedHd[CreateTime] => 2022-06-14T16:29:06+0800[UpdateTime] => 2022-06-14T16:34:24+0800[BucketId] => examplebucket-125000000[Category] => Custom[HighSpeedHd] => Array([Container] => Array([Format] => hls[ClipConfig] => Array([Duration] => 30))[Video] => Array([Codec] => H.264[Profile] => high[Bitrate] => 300[Crf] => 25[Width] => 400[Height] => 400[Fps] => 30[Gop] => 300[Preset] => veryfast[Bufsize] => 1000[Maxrate] => 300[Remove] => false[HlsTsTime] => 30[Pixfmt] => yuv420p[LongShortMode] => false[Rotate] =>)[Audio] => Array([Codec] => aac[Samplerate] => 11025[Bitrate] => 88[Channels] => 2[Remove] => false[KeepTwoTracks] => false[SwitchTrack] => false)[TransConfig] => Array([IsCheckReso] => true[IsCheckVideoBitrate] => false[IsCheckAudioBitrate] => false[ResoAdjMethod] => 0[VideoBitrateAdjMethod] => 0[AudioBitrateAdjMethod] => 0[AdjDarMethod] => none[IsStreamCopy] => false[DeleteMetadata] => false[IsHdr2Sdr] => true)[TimeInterval] => Array([Start] => 0[Duration] => 30)))))