云剪辑工程管理

通过阅读本文,您可以了解通过服务端SDK调用OpenAPI管理智能媒体服务云剪辑工程的示例代码。

注意事项

创建云剪辑工程时,Title为必选参数;如果要调用 SubmitMediaProducingJob提交剪辑合成作业,参数Timeline必须设置。

示例代码

您可以通过阿里云OpenAPI开发者门户在线调试。

package main

import (
    "fmt"
    openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
    ice "github.com/alibabacloud-go/ice-20201109/v2/client"
    "github.com/aliyun/credentials-go/credentials"
    "github.com/alibabacloud-go/tea/tea"
)

func main() {

    // 阿里云账号AccessKey拥有所有API的访问权限,建议您使用RAM用户进行API访问或日常运维。
    // 本示例以将AccessKey ID和 AccessKey Secret保存在环境变量为例说明。配置方法请参见:https://help.aliyun.com/document_detail/378661.html。
    credential, _err := credentials.NewCredential(nil)
    if _err != nil {
      panic(_err)
    }
    iceClient, _err := ice.NewClient(&openapi.Config{
      Credential: credential,
      Endpoint: tea.String("ice.cn-shanghai.aliyuncs.com"),
    })

    // 如需硬编码AccessKey ID和AccessKey Secret,代码如下,强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。
    // config := new(openapi.Config)
    // config.SetAccessKeyId("<accessKeyId>").
    //     SetAccessKeySecret("<accessKeySecret>").
    //     SetRegionId("<regionId>").
    //     SetEndpoint("<endpoint>")
    // iceClient, _err := ice.NewClient(config)

    if _err != nil {
      panic(_err)
    }

    // 创建云剪辑工程。
    title := "剪辑工程标题"
    description := "剪辑工程描述"
    timeLine := "{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****1656bca4474999c961a6d2a2****\"}]}]}"
    coverUrl := "http://****/coverUrl.jpg"
    createEditingProjectRequest := ice.CreateEditingProjectRequest{
        Title:       &title,
        Description: &description,
        Timeline:    &timeLine,
        CoverURL:    &coverUrl,
    }
    createEditingProjectResult, err := iceClient.CreateEditingProject(&createEditingProjectRequest)
    fmt.Println(createEditingProjectResult, err)

    // 获取单个云剪辑工程。
    projectId := "****4eb5fa69-56e1-4854-87e3-b0f1b6a9****"
    getEditingProjectRequest := ice.GetEditingProjectRequest{
        ProjectId: &projectId,
    }
    getEditingProjectResult, err := iceClient.GetEditingProject(&getEditingProjectRequest)
    fmt.Println(getEditingProjectResult, err)

    // 修改云剪辑工程。
    updateTimeLine := "{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"}]}]}"
    updateEditingProjectRequest := ice.UpdateEditingProjectRequest{
        ProjectId: &projectId,
        Timeline:  &updateTimeLine,
    }
    updateEditingProjectResult, err := iceClient.UpdateEditingProject(&updateEditingProjectRequest)
    fmt.Println(updateEditingProjectResult, err)

    // 删除云剪辑工程。
    deleteEditingProjectsRequest := ice.DeleteEditingProjectsRequest{
        ProjectIds: &projectId,
    }
    deleteEditingProjectsResult, err := iceClient.DeleteEditingProjects(&deleteEditingProjectsRequest)
    fmt.Println(deleteEditingProjectsResult, err)

    // 搜索云剪辑工程。
    maxResults := int64(10)
    searchEditingProjectRequest := ice.SearchEditingProjectRequest{
        MaxResults: &maxResults,
    }
    searchEditingProjectResult, err := iceClient.SearchEditingProject(&searchEditingProjectRequest)
    fmt.Println(searchEditingProjectResult, err)
}

相关接口