You need to enable JavaScript to run this app.
导航

创建转码模板

最近更新时间2023.05.22 16:16:31

首次发布时间2023.05.22 16:16:31

创建转码模板。

请求方式

使用 POST 方式发起请求。

请求参数

下表仅列出了接口特有的请求参数和部分公共参数。完整的公共参数列表,参考「公共参数」。

字段
位置
类型
必填
说明
ActionQueryString公共参数,OpenAPI 接口名称CreateTransTemplate
VersionQueryString公共参数,OpenAPI 接口版本2021-01-01

Body 参数

字段
类型
必填
说明
TemplateNameString模板名称,支持汉字、大小写字母、数字、中划线
TransArray of objects转码配置,参考以下 转码配置结构说明

转码配置结构说明

字段
类型
必填
说明

SuffixName

String

转码流后缀名。支持10个字符以内的大小写字母、下划线和中划线,注意后缀名不可包含 _uhd、_hd、_sd、_ld、或 _or4,且不可重复使用
例如:配置的转码流后缀名为 _flv,则拉转码流时转码的流名为 stream-123456789_flv

VideoBitrateInt视频码率,单位为 bps,取值范围为 [0,30000000],默认值为 1000000;取 0 时表示使用源流码率

Vcodec

String

视频编码格式:

  • h264:使用 H.264 编码格式
  • h265:使用 H.265 编码格式
  • copy:不进行转码,所有视频编码参数不生效
AudioBitrateInt音频码率,单位为 kbps

Acodec

String

音频编码格式,默认格式为 acc,支持以下 3 种类型:

  • aac:使用 aac 编码格式
  • copy:不进行转码,所有音频编码参数不生效
  • opus:使用 Opus 编码格式
FPSInt视频帧率,单位为 fps,取值范围为 [0,60],默认值为 25;帧率越大,画面越流畅
GOPIntIDR 帧之间的最大间隔,单位为 s,取值范围为 [0,1000],默认值为 0

Width

Int

视频宽度,取值范围为 [0,8192],默认值为 0
说明:

  • 当 As 的取值为 0 时,参数生效,反之则不生效
  • 当 As 的取值为 0 时,如果 Width 和 Height 任意取值为 0,表示保持源流尺寸

Height

Int

视频高度,取值范围为 [0,8192],默认值为 0
说明:

  • 当 As 的取值为 0 时,参数生效,反之则不生效
  • 当 As 的取值为 0 时,如果 Width 和 Height 任意取值为 0,表示保持源流尺寸

As

String

宽高自适应模式开关,默认值为 0,支持的取值包括:

  • 0:关闭宽高自适应,按照 Width 和 Height 的取值进行拉伸
  • 1:开启宽高自适应,按照 ShortSide 或 LongSide 等比缩放

ShortSide

Int

短边长度,默认值为 0:

  • Roi 取 false 时,取值范围为 [0,4096]
  • Roi 取 true 时,取值范围为 [0,1080]

说明:

  • 当 As 的取值为 1 时,参数生效,反之则不生效
  • 当 As 的取值为 1 时,如果 LongSide 和 ShortSide 同时取 0,表示保持源流尺寸
  • 当 As 的取值为 1 时,如果同时配置 LongSide 和 ShortSide 的值,则按照 ShortSide 进行等比缩放

LongSide

Int

长边长度,默认值为 0:

  • Roi 取 false 时,取值范围为 [0,8192]
  • Roi 取 true 时,取值范围为 [0,1920]

说明:

  • 当 As 的取值为 1 时,参数生效,反之则不生效
  • 当 As 的取值为 1 时,如果 LongSide 和 ShortSide 同时取 0,表示保持源流尺寸
  • 当 As 的取值为 1 时,如果同时配置 LongSide 和 ShortSide 的值,则按照 ShortSide 进行等比缩放

BFrames

Int

2 个参考帧之间的最大 B 帧数,不同编码格式的取值存在差异:

  • H.264:取值范围为 [0,7],默认值为 3
  • H.265:取值范围为 [0,1,2,3,7,15],默认值为 7
  • BFrames 取 0 时,表示去 B 帧

Roi

Bool

是否高清低码转码:

  • true:高清低码
  • false:标准转码(默认)

返回结果

返回参数说明

通用返回参数,请参考 ResponseMetadata 结构体说明

Result 字段包含以下参数:

字段
类型
说明
IDString创建成功的转码模板 ID

示例

请求示例

POST https://open.volcengineapi.com?Action=CreateTransTemplate
&Version=2021-01-01
&<公共请求参数>
{
    "TemplateName": "trans-template-01",
    "Trans": {
        "SuffixName": "_flv",
        "VideoBitrate": 2000000,
        "Vcodec": "h264",
        "AudioBitrate": 320,
        "Acodec": "aac",
        "FPS": 25,
        "AudioBitrate": 320,
        "GOP": 100,
        "Width": 720,
        "Height": 1280,
        "As": "1",
        "ShortSide": 1080,
        "LongSide": 1920,
        "BFrames": 3,
        "Roi": true
    }
}

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2023051811194280A4C0C428675B103F05",
        "Action": "CreateTransTemplate",
        "Version": "2021-01-01",
        "Service": "aiotvideo",
        "Region": "cn-north-1"
    },
    "Result": {
        "ID": "86a8b8ad-cbf8-425d-b662-7e8709xxxxxx"
    }
}