本文为您提供了服务端 Go SDK 的视频剪辑模块的接口调用示例。
调用接口前,请先完成集成 Go SDK。
示例中的 your ... 均需替换。Uploader 是剪辑产物上传的目标空间名称,可从视频点播控制台获取;EditParam 是剪辑配置,按各节所链接的接口文档和视频剪辑参数说明构造,不能填写空间名称;ReqId 使用提交异步剪辑任务后返回的任务 ID;CallbackUri 使用业务服务端接收回调的地址,CallbackArgs 为业务自定义透传信息。
接口请求参数和返回参数详见 OpenAPI:提交异步剪辑任务。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" "google.golang.org/protobuf/encoding/protojson" "testing" ) func Test_SubmitDirectEditTaskAsync(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) params, _ := json.Marshal(map[string]interface{}{}) query := &request.VodSubmitDirectEditTaskAsyncRequest{ Uploader: "your target store vod space", Application: "VideoTrackHighlight", EditParam: params, Priority: 0, CallbackUri: "your CallbackUri if you need", CallbackArgs: "your CallbackArgs if you need", } resp, status, err := instance.SubmitDirectEditTaskAsync(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:提交同步剪辑任务。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" "google.golang.org/protobuf/encoding/protojson" "testing" ) func Test_SubmitDirectEditTaskSync(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) params, _ := json.Marshal(map[string]interface{}{}) query := &request.VodSubmitDirectEditTaskSyncRequest{ Uploader: "your target store vod space", Application: "your application", EditParam: params, } resp, status, err := instance.SubmitDirectEditTaskSync(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:取消剪辑任务。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" "google.golang.org/protobuf/encoding/protojson" "testing" ) func Test_CancelDirectEditTask(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodCancelDirectEditTaskRequest{ ReqId: "your ReqId here", } resp, status, err := instance.CancelDirectEditTask(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:查询任务进度。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" "google.golang.org/protobuf/encoding/protojson" "testing" ) func Test_GetDirectEditProgress(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodGetDirectEditProgressRequest{ ReqId: "your ReqId here", } resp, status, err := instance.GetDirectEditProgress(query) fmt.Println(status) fmt.Println(err) op := &protojson.MarshalOptions{ EmitUnpopulated: true, } format := op.Format(resp) fmt.Println(format) }
返回结果 Result 参数说明如下所示。
ResponseMetadata:{ RequestId:"2022102***2121601360E968B6F" Action:"GetDirectEditProgress" Version:"2018-01-01" Service:"vod" Region:"cn-north-1" } Result:{ }
ResponseMetadata:{ RequestId:"2022102815***21601360E968B6F" Action:"GetDirectEditProgress" Version:"2018-01-01" Service:"vod" Region:"cn-north-1" } Result:{ Result:100 }
接口请求参数和返回参数详见 OpenAPI:查询任务详情。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" "google.golang.org/protobuf/encoding/protojson" "testing" ) func Test_GetDirectEditResult(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodGetDirectEditResultRequest{ ReqIds: []string{"your ReqId here"}, } resp, status, err := instance.GetDirectEditResult(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }