为了在白板互动中共享文件,你可能需要将文档转为静态图片或动态的 HTML5 页面。通过调用服务端 OpenAPI WbTranscodeCreate 发起文档转码任务。
转码的任务处理是异步的,你可以通过 WbTranscodeQuery 查询到转码任务完成后,调用 WbTranscodeGet 获取转换好的链接集合。
调用服务端接口完成文档转码后,你还需要调用客户端接口,将转码后的文档共享到白板房间。文件上传的完整流程参见 文档上传。
WbTranscodeCreate 发起一个文档转码任务。
- 调用本接口前,你需要先将文件上传到 TOS。
- 如果你需要对多个文件进行转码,请分别调用
WbTranscodeCreate传入相应的文件和参数设置。
使用 Post 方式发起请求。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | string | 是 | WbTranscodeCreate | 接口名称,本接口取值:WbTranscodeCreate |
| Version | string | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| app_id | string | 是 | 600000000000000000000000 | 应用的唯一标志。你可以通过控制台查看和复制你的 app_id。或通过调用 ListApps 接口获取。 |
| resource | string | 是 | https://resource.com | 需要转换为图片的文档链接地址。每次调用接口只能请求处理一份文档。 |
| resource_attr | ResourceAttr | 动态转码必填,静态转码无需填写 | 动态转码文件设置 | |
| operator | string | 是 | your_user_id | 用户 ID |
transcode_config | 静态转码必填,动态转码无需填写 | | 转码参数设置 | |
storage_config |
| | 对象存储属性
| |
transcode_mode | int | 否 |
| 转码类型 |
priority | int | 否 |
| 静态转码的转码优先级
|
pre_sign_duration | int | 否 |
| 转码成功后返回的 URL 预签名有效期。有效范围:
|
https://rtc.volcengineapi.com?Action=WbTranscodeCreate&Version=2020-12-01
postscript{
"app_id":"600000000000000000000000",
"oprator":"your_user_id",
"resource":"https://resource.com",
"priority":0,
"transcode_config":{
"input_format":1,
"output_format":1,
"output_width":1080,
"output_height":720
},
"storage_config":{
"type":0,
"tos_config":{
"account_id":"xxx",
"region":0,
"bucket":"xxx"
}
}
}
json{
"ResponseMetadata": {
"RequestId": "your_request_id",
"Service": "rtc",
"Region": "cn-north-1",
"Action": "WbTranscodeCreate",
"Version": "2020-12-01"
},
"Result": {
"task_id": "xxx" //task_id 为查询任务进度和获取转码后链接的必填参数
}
}
json发起文档转码任务,可以通过调用 WbTranscodeQuery 查询转码任务的进度。
使用 Get 方式发起请求。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | string | 是 | WbTranscodeQuery | 接口名称,本接口取值:WbTranscodeQuery |
| Version | string | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
app_id | string | 是 |
| |
| task_id | string | 是 | 0000000000 | 成功调用 WbTranscodeQuery后返回的任务ID |
https://rtc.volcengineapi.com?Action=WbTranscodeQuery&Version=2020-12-01&app_id=your_app_id&task_id=your_task_id
postscript| 参数名 | 类型 | 必须 | 说明 |
|---|---|---|---|
status | int | 是 | 转码任务状态
|
progress err_code | int int | 否 否 | 静态转码进度。 |
| err_msg | string | 否 | 错误信息 |
{
"ResponseMetadata": {
"RequestId": "your_request_id",
"Service": "rtc",
"Region": "cn-north-1",
"Action": "WbTranscodeQuery",
"Version": "2020-12-01"
},
"Result": {
"status": 2, // 0:未开始,1:进行中,2:已完成:3:失败
"progress": 100,
"err_code": 0,
"err_msg": ""
}
}
json文档转码任务完成后,可以通过 WbTranscodeGet 获取文档转码后的链接。
使用 Get 方式发起请求。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | string | 是 | WbTranscodeGet | 接口名称,本接口取值:WbTranscodeGet |
| Version | string | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
app_id | string | 是 |
| |
| task_id | string | 是 | 0000000000 | 成功调用 WbTranscodeQuery后返回的任务ID |
https://rtc.volcengineapi.com?Action=WbTranscodeGet&Version=2020-12-01&app_id=your_app_id&task_id=your_task_id
json以静态转码任务为例。与动态转码不同,静态转码的返回值不包含 file_id 参数。
{
"ResponseMetadata": {
"RequestId": "your_request_id",
"Service": "rtc",
"Region": "cn-north-1",
"Action": "WbTranscodeGet",
"Version": "2020-12-01"
},
"Result": {
"file_name": "cs.pptx",
"width": 1920,
"height": 1080,
"transcode_mode": 0,
"images": [
{
"page_id": 1,
"img": "https://result1.com",
"thumbnail_url": "https://result1_thm.com"
},
{
"page_id": 2,
"img": "https://result2.com",
"thumbnail_url": "https://result2_thm.com"
}
],
"h5_url": ""
}
json| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
| file_name | string | 是 | 文件名 |
| size | int | 是 | 文件大小,单位:byte |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
input_format | int | 是 | 输入文件类型 |
output_format | int | 是 | 输出文件类型 |
force_use_resolution | bool | 否 | 是否按照指定分辨率拉伸页面 |
| output_width | int | 是 | 转码后的页面宽度,单位为像素 |
| output_height | int | 是 | 转码后的页面高度,单位为像素 |
| thumbnail | bool | 否 | 是否生成缩略图,默认为 false |
| thumbnail_width | int | 否 | 缩略图分辨率宽,默认为 320 |
| thumbnail_height | int | 否 | 缩略图分辨率高,默认为 180 |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
type | int | 是 | 存储类型 |
| tos_config | TosConfig | 否 | 火山引擎的对象存储服务参数设置 |
| custom_config | CustomConfig | 否 | 第三方对象存储服务参数设置 |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
account_id | string | 是 | Bucket 所属的火山引擎账号 ID。在登陆火山引擎后,可在头像的悬浮菜单中找到账号 ID。 |
| region | int | 是 | 0: 北京 |
| bucket | string | 是 | 桶名称。登陆 TOS 控制台 开通和获取。 |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
vendor | int | 是 | 第三方存储供应商 |
region | int | 是 | 区域 |
| bucket | string | 是 | 桶名称 |
| access_key | string | 是 | Access Key |
secret_key | stiring | 是 | Secret Key |