有奖捉虫:云通信与企业服务文档专题,速来> HOT

简介

本文档提供关于极速高清转码模板接口的 API 概览和 SDK 示例代码。
API
操作描述
用于新增极速高清转码模板
用于更新极速高清转码模板

新增极速高清转码模板

功能说明

用于新增极速高清转码模板。

方法原型

public Guzzle\\Service\\Resource\\Model createMediaHighSpeedHdTemplate(array $args = array());

请求示例

<?php

require 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,
'scheme' => '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
模板名称。仅支持中文、英文、数字、_、-和*
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
Profile
Request.Video
编码级别
String
high
1. 支持 baseline、main、high
2. baseline:适合移动设备
3. main:适合标准分辨率设备
4. high:适合高分辨率设备
5. 仅H.264 支持此参数
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
值范围:[0, 100000]
Preset
Request.Video
视频算法器预置
String
medium
1. 仅H.264支持该参数
2. 取值 veryfast、fast、medium、slow、slower
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
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
当 Codec 设置为 aac,支持1、2、4、5、6、8
当 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
取值0、1;0 表示使用原视频分辨率;1表示返回转码失败
当 IsCheckReso 为 true 时生效
IsHdr2Sdr
Request.TransConfig
是否开启 HDR 转 SDR
String
false
true/false

返回结果示例

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());

请求示例

<?php

require 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,
'scheme' => '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 中的具体数据描述如下:
节点名称(关键字)
父节点
描述
Tag
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.Tag
Name
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.Name
TimeInterval
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.TimeInterval
Container
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.Container
Video
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.Video
Audio
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.Audio
TransConfig
Request
同极速高清模板 CreateMediaTemplate 接口中的 Request.TransConfig

返回结果示例

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
)

)

)

)

)