全部产品

剪辑合成

本文介绍如何通过ICE Go SDK创建合成任务。

创建合成任务

创建合成任务有三种方式:

  • 通过时间线创建

  • 通过模板创建

  • 通过project创建

以上三种方式任选其一

获取单个合成任务

通过GetMediaProducingJob接口获取合成任务的输入、输出及状态。

代码示例

package main

import (
 "fmt"

 client2 "github.com/alibabacloud-go/darabonba-openapi/client"
 ice "github.com/alibabacloud-go/ice-20201109/client"
)

func main() {
 iceClient, err := InitICEClient("<yourAccessKeyId>", "<yourAccessKeySecret>")

 // 通过timeline创建合成任务
 timeLine :="{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****1656bca4474999c961a6d2a2****\"}]}]}"
 produceTarget := "{\"mediaURL\":\"http://ice-editing.oss-cn-hangzhou.aliyuncs.com/ice/\",\"type\":\"unkown\"}"
 projectMedia := "{\"coverURL\":\"http://****/mediaid.jpg\",\"description\":\"description\",\"title\":\"title\",\"tags\":\"Tag1,Tag2,Test\"}"

 submitMediaProducingJobRequest := ice.SubmitMediaProducingJobRequest{
  Timeline: &timeLine,
  ProduceTarget: &produceTarget,
  ProjectMetadata: &projectMedia,
 }
 submitMediaProducingJobResult, err := iceClient.SubmitMediaProducingJob(&submitMediaProducingJobRequest)
 fmt.Println(submitMediaProducingJobResult, err)

 // 通过模板创建合成任务
 templateId := "IceSys_VideoMerge"
 clipsParam := "{\"VideoArray\":[\"****g105512043f49f697f74258u****\",\"****f82788e810116a45109f2ebb****\",\"****f267f44f4964e6c998dee89i****\",]}"

 submitMediaProducingJobRequest1 := ice.SubmitMediaProducingJobRequest{
  TemplateId: &templateId,
  ClipsParam: &clipsParam,
  ProjectMetadata: &projectMedia,
 }
 submitMediaProducingJobResult1, err := iceClient.SubmitMediaProducingJob(&submitMediaProducingJobRequest1)
 fmt.Println(submitMediaProducingJobResult1, err)


 // 通过project创建合成任务
 projectId := "****9b4d7cf14dc7b83b0e801cbe****"

 submitMediaProducingJobRequest2 := ice.SubmitMediaProducingJobRequest{
  ProjectId: &projectId,
  ProjectMetadata: &produceTarget,
 }
 submitMediaProducingJobResult2, err := iceClient.SubmitMediaProducingJob(&submitMediaProducingJobRequest2)
 fmt.Println(submitMediaProducingJobResult2, err)


 // 获取单个合成任务
 jobId := "****967f44f4964e6c998dee8e****"

 getMediaProducingJobRequest := ice.GetMediaProducingJobRequest{
  JobId: &jobId,
 }
 getMediaProducingJobResult, err := iceClient.GetMediaProducingJob(&getMediaProducingJobRequest)
 fmt.Println(getMediaProducingJobResult, err)

}

func InitICEClient(accessKeyId string, accessKeySecret string) (client *ice.Client, err error) {

 // ICE接入区域
 regionId := "cn-shanghai"

 // ICE EndPoint
 endPoint := "ice.cn-shanghai.aliyuncs.com"

 config := new(client2.Config)
 config.SetAccessKeyId(accessKeyId).
  SetAccessKeySecret(accessKeySecret).
  SetRegionId(regionId).
  SetEndpoint(endPoint)


 // 创建ICEClient实例
 return ice.NewClient(config)
}