模板接口

最近更新时间:2024-07-11 17:06:22

我的收藏

简介

本文档提供关于模板接口的 API 概览以及 SDK 示例代码。
说明:
阅读本文档前请先打开示例代码



创建模板

接口文档及示例函数名

API 文档
示例函数名
ci_create_transcode_template
ci_create_high_speed_hd_template
ci_create_video_montage_template
ci_create_watermark_template
ci_create_snapshot_template
ci_create_animation_template
ci_create_contact_template
ci_create_transcode_pro_template
ci_create_smart_cover_template
ci_create_pic_process_template
ci_create_asr_template
ci_create_tts_template
ci_create_voice_separate_template
ci_create_noise_reduction_template
ci_create_video_target_template

示例代码

以创建音视频转码模板为例
transcode_template_config = {
# 模板名称,仅支持中文、英文、数字、_、-和*,长度不超过 64 # 必选
'Name': 'transcode_template',
# 模板类型:转码模板固定值为 Transcode
# 必选
'Tag': 'Transcode',
# 容器格式
# 必选
'Container': {
# 封装格式
# 必选
'Format': 'hls',
# 分片配置,当 format 为 hls 和 dash 时有效
# 非必选
'ClipConfig': {
# 分片时长
# 非必选,默认5s
'Duration': '5'
}
},
# 转码视频流配置信息
# 非必选
'Video': {
# 编解码格式
# H.264 H.265 VP8 VP9 AV1
# 非必选,H.264,当 Format 为 WebM 时,为 VP8
'Codec': 'H.264',
}
}

def ci_create_transcode_template():
# 创建转码模板
response = client.ci_create_template(
Bucket=bucket_name,
Template=transcode_template_config,
)
print(response)
return response


更新模板

接口文档及示例函数名

API 文档
示例函数名
ci_update_transcode_template
ci_update_high_speed_hd_template
ci_update_video_montage_template
ci_update_watermark_template
ci_update_snapshot_template
ci_update_animation_template
ci_update_contact_template
ci_update_transcode_pro_template
ci_update_smart_cover_template
ci_update_pic_process_template
ci_update_asr_template
ci_update_tts_template
ci_update_voice_separate_template
ci_update_noise_reduction_template
ci_update_video_target_template

示例代码

以更新音视频转码模板为例
transcode_template_config = {
# 模板名称,仅支持中文、英文、数字、_、-和*,长度不超过 64 # 必选
'Name': 'transcode_template',
# 模板类型:转码模板固定值为 Transcode
# 必选
'Tag': 'Transcode',
# 容器格式
# 必选
'Container': {
# 封装格式
# 必选
'Format': 'hls',
# 分片配置,当 format 为 hls 和 dash 时有效
# 非必选
'ClipConfig': {
# 分片时长
# 非必选,默认5s
'Duration': '5'
}
},
# 转码视频流配置信息
# 非必选
'Video': {
# 编解码格式
# H.264 H.265 VP8 VP9 AV1
# 非必选,H.264,当 Format 为 WebM 时,为 VP8
'Codec': 'H.264',
}
}

def ci_update_transcode_template():
# 更新转码模板
response = client.ci_update_template(
Bucket=bucket_name,
TemplateId='t13eb9cabe8xxxxxxxxxxxxxxxxxxxx',
Template=transcode_template_config,
)
print(response)
return response


查询模板

接口文档及示例函数名

API 文档
示例函数名
ci_get_template

示例代码

def ci_get_template():
response = client.ci_get_template(
Bucket=bucket_name,
)
print(response)
return response


删除模板

接口文档及示例函数名

API 文档
示例函数名
ci_delete_template

示例代码

def ci_delete_template():
response = client.ci_delete_template(
Bucket=bucket_name,
TemplateId='t13eb9cabe8xxxxxxxxxxxxxxxxxxxx',
)
print(response)
return response