视频生成音乐

功能介绍

视频生成音乐能力,可以根据用户输入的视频来进行音乐创作,输出成品音乐及配乐视频等结果

接口说明

请求方式: POST(HTTP)

请求地址: http://service-mqk0mc83-1257411467.bj.apigw.tencentcs.com/release/job

请求头: Content-Type: application/json

请求流程: 接口包括‘创建任务’,‘查询任务’。创建任务后,用户可以主动查询任务来知晓任务结果,也可以在创建任务时输入回调地址(callback),则任务在完成后会自动回调该地址

其他要求: 文件格式:"mp4",时长建议在5min内

创建任务

参数说明

参数 是否必选 类型 说明
action string 公共参数,此处为 CreateJob
secretId string 公共参数,用户 SecretId
secretKey string 公共参数,用户 secretKey
createJobRequest object
- inputs Array of Input Input,输入结构体数组
- outputs Array of Output Output,输出结构体数组
- callback string 回调地址,默认:不开启回调
- customId string 用户自定义任务 ID,小于 64 字符
- timeout int 任务超时时间,单位秒。超过超时时间后任务会被置为 ERROR

Input

参数 是否必选 类型 说明
url string 源 url 地址,与 source 字段二选一填写
source object 仓库源设置,与 url 字段二选一填写
- contentId string 仓库 ID
- path string 源路径

Output

参数 是否必选 类型 说明
contentId string 仓库 ID,默认:空
destination string 输出目录,默认:'/' (即根目录)
inputSelectors Array of int 该输出的输入源
smartContentDescriptor SmartContentDescriptor 智能能力的描述,默认:空
- outputPrefix string 输出文件前缀,小于 20 字符,默认:空
- videoBgmGeneration object 视频生成音乐
-- bgmNum int 输出数量, 范围[1,9]
-- mode Mode enum 模式设置,默认:单轨模式
-- emotion Emotion enum 生成的音乐情感设置,仅单轨模式生效,默认"auto"

Mode

含义
1 SINGLE_TRACK
2 MULTI_TRACE
3 MULTI_TRACK_EMOTION

Emotion

含义
1 AUTO
2 EXCITING
3 FEAR
4 FUNNY
5 HAPPY
6 LAZY
7 MAGNIFICENT
8 QUIET
9 ROMANTIC
10 SAD
11 ANGRY(仅当mode为MULTI_TRACE或MULTI_TRACK_EMOTION时有效)
12 WARM(仅当mode为MULTI_TRACE或MULTI_TRACK_EMOTION时有效)

请求示例:

{
  "action": "CreateJob",
  "secretId": "{secretId}",
  "secretKey": "{secretKey}",
  "createJobRequest": {
    "customId": "{customId}",
    "callback": "{callback}",
    "inputs": [
      {
        "url": "{url}"
      }
    ],
    "outputs": [
      {
        "contentId": "{contentId}",
        "destination": "/output",
        "inputSelectors": [0],
        "smartContentDescriptor": {
          "outputPrefix": "{outputPrefix}",
          "videoBgmGeneration": {
            "bgmNum": 1
          }
        }
      }
    ]
  }
}

返回示例:

{
  "requestId": "ac004192-110b-46e3-ade8-4e449df84d60",
  "createJobResponse": {
    "job": {
      "id": "13f342e4-6866-450e-b44e-3151431c578b",
      "state": 1,
      "customId": "{customId}",
      "callback": "{callback}",
      "inputs": [
        {
          "url": "{url}"
        }
      ],
      "outputs": [
        {
          "contentId": "{contentId}",
          "destination": "{destination}",
          "inputSelectors": [0],
          "smartContentDescriptor": {
            "outputPrefix": "{outputPrefix}",
            "videoBgmGeneration": {
              "bgmNum": 1
            }
          }
        }
      ],
      "timing": {
        "createdAt": "1603432763000",
        "startedAt": "0",
        "completedAt": "0"
      }
    }
  }
}

State

含义
1 SUBMITTED
2 PROCESSING
3 COMPLETED
4 ERROR
5 CANCELED

获取任务信息

获取方式:分为主动获取和被动回调。

  • 主动获取按照 id 的类别有两种查询接口,一种是根据用户自定义 id 查询,由于平台无法保证该 id 的唯一性,故返回 Job 数组(见 1);另一种是通过创建任务后的回包中的 id 查询(见 2)
  • 被动回调需要在创建任务时填写 callback 字段,平台在任务进入完成态(COMPLETED/ERROR)后会将 Job 结构体发送给 callback 所指的地址(见 3),平台方推荐使用被动回调的方式获取任务结果。

在视频生成音乐能力中,如果查询到的任务成功(state=3),则任务的 Output 中会携带 smartContentResult 结构体,其中的videoBgmGeneration结构体(Arrary of VideoBgmGenerationResult)存储输出文件名信息。用户根据 Output 中的 cos 及 destination 信息可自行拼接出输出文件的 cos 路径。

VideoBgmGenerationResult

参数 类型 说明
bgmName string 音乐文件名称
videoName string 视频文件名称

1. 主动查询,根据用户在新建任务时传入的自定义 customId 请求示例:

{
  "action": "ListJobs",
  "secretId": "{secretId}",
  "secretKey": "{secretKey}",
  "listJobsRequest": {
    "customId": "{customId}"
  }
}

返回示例:

{
  "requestId": "c9845a99-34e3-4b0f-80f5-f0a2a0ee8896",
  "listJobsResponse": {
    "jobs": [
      {
        "id": "a95e9d74-6602-4405-a3fc-6408a76bcc98",
        "state": 3,
        "customId": "{customId}",
        "callback": "{callback}",
        "timing": {
          "createdAt": "1610513575000",
          "startedAt": "1610513575000",
          "completedAt": "1610513618000"
        },
        "inputs": [{ "url": "{url}" }],
        "outputs": [
          {
            "contentId": "{contentId}",
            "destination": "{destination}",
            "inputSelectors": [0],
            "smartContentDescriptor": {
              "outputPrefix": "{outputPrefix}",
              "videoBgmGeneration": {
                "bgmNum": 1
              }
            },
            "smartContentResult": {
              "videoBgmGeneration": [{
                "bgmName": "bgm.mp3",
                "videoName": "video.mp4"
              }]
            }
          }
        ]
      }
    ],
    "total": 1
  }
}

2. 主动查询,根据新建任务时回包带的 id 请求示例:

{
  "action": "GetJob",
  "secretId": "{secretId}",
  "secretKey": "{secretKey}",
  "getJobRequest": {
    "id": "{id}"
  }
}

返回示例:

{
  "requestId": "c9845a99-34e3-4b0f-80f5-f0a2a0ee8896",
  "getJobResponse": {
    "job": {
      "id": "a95e9d74-6602-4405-a3fc-6408a76bcc98",
      "state": 3,
      "customId": "{customId}",
      "callback": "{callback}",
      "timing": {
        "createdAt": "1610513575000",
        "startedAt": "1610513575000",
        "completedAt": "1610513618000"
      },
      "inputs": [{ "url": "{url}" }],
      "outputs": [
        {
          "contentId": "{contentId}",
          "destination": "{destination}",
          "inputSelectors": [0],
          "smartContentDescriptor": {
            "outputPrefix": "{outputPrefix}",
            "videoBgmGeneration": {
              "bgmNum": 1
            }
          },
          "smartContentResult": {
            "videoBgmGeneration": [{
              "bgmName": "bgm.mp3",
              "videoName": "video.mp4"
            }]
          }
        }
      ]
    }
  }
}

3. 被动回调

会将进入完成态(COMPLETED/ERROR)的任务的整个 Job 结构体发送到用户在创建任务时指定的 callback 字段对应的地址,Job 结构体见主动查询的示例(getJobResponse 下)

腾讯多媒体实验室
/
我们希望使用性能和分析 cookies(“Cookie”)来帮助我们识别您是否是回访者并跟踪网站浏览次数和访问次数。有关我们使用的 Cookie 和您的选项(包括如何更改您的偏好)的更多信息,请参阅我们的 Cookies 策略.